@SuppressWarnings("unchecked")
    public static void main(String[] args) throws Exception {
        Map<String, String> argsMap = new HashMap<>();

        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("help")) {
                printHelp();
            }

            System.out.print("Argument: " + args[i]);
            String[] splitArg = args[i].split("=");

            if (splitArg.length == 2) {
                System.out.println(" is valid");
                argsMap.put(splitArg[0], splitArg[1]);
            } else {
                System.out.println(" is invalid");
            }
        }

        StorageConfiguration config;
        File configFile;
        Class<? extends IBackend> backendClass;
        Class<? extends IRevisioning> revisioningClass;
        boolean create = false;

        System.out.println("\nThis system provides more than one IP Address to advertise.\n");

        Enumeration<NetworkInterface> interfaceEnum = NetworkInterface.getNetworkInterfaces();
        NetworkInterface i;
        int addressCounter = 0;
        List<InetAddress> addresses = new ArrayList<InetAddress>();
        while (interfaceEnum.hasMoreElements()) {
            i = interfaceEnum.nextElement();
            Enumeration<InetAddress> addressEnum = i.getInetAddresses();
            InetAddress address;

            while (addressEnum.hasMoreElements()) {
                address = addressEnum.nextElement();
                System.out.println("[" + addressCounter + "] " + address.getHostAddress());
                addresses.add(address);
                addressCounter++;
            }
        }

        /*
         * Getting the desired address from the command line.
         * You can't automatically make sure to always use the correct
         * host address.
         */
        System.out.print("\nWhich one should be used?\nType in the number: ");
        Integer chosenIndex = null;

        while (chosenIndex == null) {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();
            try {
                chosenIndex = Integer.parseInt(line);
            } catch (NumberFormatException nfe) {
                chosenIndex = null;
            }
        }

        String targetAddress = addresses.get(chosenIndex).getHostAddress();
        System.out.println("Using ip address " + addresses.get(chosenIndex).getHostAddress());

        if (argsMap.get("storagePath") != null) {
            File file = new File(argsMap.get("storagePath"));
            config = new StorageConfiguration(file);
        } else {
            // String file = Files.createTempDir().getAbsolutePath();
            String file = "/tmp/tttarget";
            config =
                new StorageConfiguration(new File(new StringBuilder(file).append(File.separator)
                    .append("tnk").append(File.separator).append("path1").toString()));
        }

        if (argsMap.get("targetConfiguration") != null) {
            configFile = new File(argsMap.get("targetConfiguration"));
        } else {
            configFile = TreetankConfiguration.CONFIGURATION_CONFIG_FILE;
        }

        if (argsMap.get("backendImplementation") != null) {
            backendClass = (Class<? extends IBackend>)Class.forName(argsMap.get("backendImplementation"));
        } else {
            backendClass = CombinedStorage.class;
        }

        if (argsMap.get("revisioningImplementation") != null) {
            revisioningClass =
                (Class<? extends IRevisioning>)Class.forName(argsMap.get("revisioningImplementation"));
        } else {
            revisioningClass = SlidingSnapshot.class;
        }

        if (argsMap.get("create") != null) {
            if(argsMap.get("create").toLowerCase().equals("true")){
                create = true;
            }
        }

        if(create){
            Storage.truncateStorage(config);
        	IOUtils.recursiveDelete(config.mFile);
            Storage.createStorage(config);
        }

        final String resourceName = "bench53473ResourcegraveISCSI9284";

        // Guice Stuff for building the module
        final Properties props = StandardSettings.getProps(config.mFile.getAbsolutePath(), resourceName);
        final Injector injector =
            Guice.createInjector(new ModuleSetter().setDataFacClass(BlockDataElementFactory.class)
                .setMetaFacClass(ISCSIMetaPageFactory.class).setBackendClass(backendClass)
                .setRevisioningClass(revisioningClass).createModule());
        final IResourceConfigurationFactory resFac =
            injector.getInstance(IResourceConfigurationFactory.class);
        final ResourceConfiguration resConf = resFac.create(props);

        final IStorage db = Storage.openStorage(config.mFile);
        db.createResource(resConf);
        final ISession session = db.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY));

        TargetServer target =
            new TargetServer(TreetankConfiguration.create(TreetankConfiguration.CONFIGURATION_SCHEMA_FILE,
                configFile, session, targetAddress));

        target.call();
    }
@ SuppressWarnings ( "unchecked" ) public static void main ( String [ ] args ) throws Exception { Map < String , String > argsMap = new HashMap < > ( ) ; for ( int i = 0 ; i < args . length ; i ++ ) { if ( args [ i ] . equals ( "help" ) ) { printHelp ( ) ; } System . out . print ( "Argument: " + args [ i ] ) ; String [ ] splitArg = args [ i ] . split ( "=" ) ; if ( splitArg . length == 2 ) { System . out . println ( " is valid" ) ; argsMap . put ( splitArg [ 0 ] , splitArg [ 1 ] ) ; } else { System . out . println ( " is invalid" ) ; } } StorageConfiguration config ; File configFile ; Class < ? extends IBackend > backendClass ; Class < ? extends IRevisioning > revisioningClass ; boolean create = false ; System . out . println ( "\nThis system provides more than one IP Address to advertise.\n" ) ; Enumeration < NetworkInterface > interfaceEnum = NetworkInterface . getNetworkInterfaces ( ) ; NetworkInterface i ; int addressCounter = 0 ; List < InetAddress > addresses = new ArrayList < InetAddress > ( ) ; while ( interfaceEnum . hasMoreElements ( ) ) { i = interfaceEnum . nextElement ( ) ; Enumeration < InetAddress > addressEnum = i . getInetAddresses ( ) ; InetAddress address ; while ( addressEnum . hasMoreElements ( ) ) { address = addressEnum . nextElement ( ) ; System . out . println ( "[" + addressCounter + "] " + address . getHostAddress ( ) ) ; addresses . add ( address ) ; addressCounter ++ ; } } System . out . print ( "\nWhich one should be used?\nType in the number: " ) ; Integer chosenIndex = null ; while ( chosenIndex == null ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; try { chosenIndex = Integer . parseInt ( line ) ; } catch ( NumberFormatException nfe ) { chosenIndex = null ; } } String targetAddress = addresses . get ( chosenIndex ) . getHostAddress ( ) ; System . out . println ( "Using ip address " + addresses . get ( chosenIndex ) . getHostAddress ( ) ) ; if ( argsMap . get ( "storagePath" ) != null ) { File file = new File ( argsMap . get ( "storagePath" ) ) ; config = new StorageConfiguration ( file ) ; } else { String file = "/tmp/tttarget" ; config = new StorageConfiguration ( new File ( new StringBuilder ( file ) . append ( File . separator ) . append ( "tnk" ) . append ( File . separator ) . append ( "path1" ) . toString ( ) ) ) ; } if ( argsMap . get ( "targetConfiguration" ) != null ) { configFile = new File ( argsMap . get ( "targetConfiguration" ) ) ; } else { configFile = TreetankConfiguration . CONFIGURATION_CONFIG_FILE ; } if ( argsMap . get ( "backendImplementation" ) != null ) { backendClass = ( Class < ? extends IBackend > ) Class . forName ( argsMap . get ( "backendImplementation" ) ) ; } else { backendClass = CombinedStorage . class ; } if ( argsMap . get ( "revisioningImplementation" ) != null ) { revisioningClass = ( Class < ? extends IRevisioning > ) Class . forName ( argsMap . get ( "revisioningImplementation" ) ) ; } else { revisioningClass = SlidingSnapshot . class ; } if ( argsMap . get ( "create" ) != null ) { if ( argsMap . get ( "create" ) . toLowerCase ( ) . equals ( "true" ) ) { create = true ; } } if ( create ) { Storage . truncateStorage ( config ) ; IOUtils . recursiveDelete ( config . mFile ) ; Storage . createStorage ( config ) ; } final String resourceName = "bench53473ResourcegraveISCSI9284" ; final Properties props = StandardSettings . getProps ( config . mFile . getAbsolutePath ( ) , resourceName ) ; final Injector injector = Guice . createInjector ( new ModuleSetter ( ) . setDataFacClass ( BlockDataElementFactory . class ) . setMetaFacClass ( ISCSIMetaPageFactory . class ) . setBackendClass ( backendClass ) . setRevisioningClass ( revisioningClass ) . createModule ( ) ) ; final IResourceConfigurationFactory resFac = injector . getInstance ( IResourceConfigurationFactory . class ) ; final ResourceConfiguration resConf = resFac . create ( props ) ; final IStorage db = Storage . openStorage ( config . mFile ) ; db . createResource ( resConf ) ; final ISession session = db . getSession ( new SessionConfiguration ( resourceName , StandardSettings . KEY ) ) ; TargetServer target = new TargetServer ( TreetankConfiguration . create ( TreetankConfiguration . CONFIGURATION_SCHEMA_FILE , configFile , session , targetAddress ) ) ; target . call ( ) ; }
Starts the jSCSI target.

Argument one has to be an empty (or already created) storage folder!
Argument to can be additionally added if you don't want the default target configuration.
It has to be conform with the default target configuration schema file, which you can find
in the resources of the target.

@param args
storagePath=<PathToStorage> | If using an existing storage, make sure not to pass a backend
implementation or revisioning implementation again.
targetConfiguration=<PathToTargetConfigurationFile> | This usually is an .xml-File that
corresponds to the one that can be found in the sources.
backendImplementation=<FullyQualifiedPath> | E.g.: org.treetank.io.combined.CombinedStorage
(which also is default)
revisioningImplementation=<FullyQualifiedPath> | E.g.:
org.treetank.revisioning.SlidingSnapshot (which also is default)

@throws Exception