Integration Toolbox
for IBM® TIVOLI® Storage Manager

package filespace; import hu.user.toolbox.tsm.IFilespace; import hu.user.toolbox.tsm.ITSMSession; import hu.user.toolbox.tsm.Toolbox; import hu.user.toolbox.tsm.exception.ToolboxException; /** * <b>Function:</b><br> * Updates a filespace. * <p> * Before executing this program register a filespace using the RegisterFilespace sample. * <p> * The following operations are performed: * <ol> * <li>Initializing a single-threaded TSM API environment.</li> * <li>Creating a new TSMSession instance. * Setting default connection options. Connecting to the server using * the node name "TOOLBOX" and password "PASSWORD".</li> * <li>Retrieving the filespace with the name from command line arguments.</li> * <li>Updating the values.</li> * <li>Disconnecting from the server and cleaning up the resources.</li> * </ol> * <p> * <b>Compile:</b> * <pre> * javac -d bin -cp ../lib/toolboxfortsm.jar filespace/ * </pre> * <p> * <b>Execute:</b><br> * You should first set the environment variables to point to the correct * files/directories. * <pre> * set DSMI_CONFIG={Full path of your dsm.opt} * set DSMI_DIR={Tivoli Storage Manager API installation directory} * set DSMI_LOG={Any arbitrary directory} * </pre> * Then use the java command to execute the program: * <p> * <pre> * java -cp bin:../lib/toolboxfortsm.jar:../lib/ext/log4j-1.2.17.jar:../config * -Djava.library.path=../lib filespace.UpdateFilespace {filespace-name} * </pre> */ public class UpdateFilespace { private static final String NODE_NAME = "TOOLBOX"; private static final String PASSWORD = "PASSWORD"; private static final long CAPACITY_UPDATED = 1000; private static final long OCCUPANCY_UPDATED = 25; private static final String INFORMATION_UPDATED = "Toolbox for TSM - updated"; public static void main(String args[]) throws ToolboxException{ String filespaceName = null; if(args.length <1){ System.out.println("Usage: java UpdateFilespace {filespace name}."); return; } else { filespaceName = args[0]; } ITSMSession session = null; try { // Initializing a single-threaded environment Toolbox.initSingleThreading(); // Connecting to the server with the default connection options session =Toolbox.createSession(NODE_NAME, PASSWORD); // Retrieving a existing filespace IFilespace filespace = session.retrieveFilespace(filespaceName); // Checking if filespace exists if (filespace == null) { System.out.printf("Warning: '%s' does not exists.\n", filespaceName); return; } System.out.println("The original fields of the filespace:\n"); printDetails(filespace); // Setting the updated fields filespace.setCapacity(CAPACITY_UPDATED); filespace.setOccupancy(OCCUPANCY_UPDATED); filespace.setInformation(INFORMATION_UPDATED); // Updating the fields filespace.update(); System.out.println("The updated fields of the filespace:\n"); printDetails(filespace); } catch (Exception e) { e.printStackTrace(); }finally{ session.disconnect(); Toolbox.cleanUp(); } } /** * Prints the details of a filespace. * * @param o the {@code IFilespace} object */ private static void printDetails(IFilespace o){ System.out.printf(" Filespace name: %s\n", o.getName()); System.out.printf(" Type: %s\n", o.getType()); System.out.printf(" Information: %s\n", o.getInformation()); System.out.printf("Occupancy (bytes): %d\n", o.getOccupancy()); System.out.printf(" Capacity (bytes): %d\n", o.getCapacity()); System.out.printf("Backup start date: %s\n", o.getBackupStartDate()); System.out.printf(" Backup end date: %s\n", o.getBackupCompleteDate()); System.out.println(); } }