Search in sources :

Example 1 with DataServerImpl

use of cbit.vcell.simdata.DataServerImpl in project vcell by virtualcell.

the class VirtualFrapWindowManager method startExport.

public void startExport(Component requester, OutputContext outContext, ExportSpecs exportSpecs) {
    try {
        ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
        DataServerImpl dataServerImpl = new DataServerImpl(localWorkSpace.getDataSetControllerImpl(), exportServiceImpl);
        exportServiceImpl.addExportListener(new ExportListener() {

            public void exportMessage(ExportEvent event) {
                System.out.println(event.toString());
            }
        });
        exportServiceImpl.makeRemoteFile(null, LocalWorkspace.getDefaultOwner(), dataServerImpl, exportSpecs);
    } catch (DataAccessException e) {
        e.printStackTrace(System.out);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : DataServerImpl(cbit.vcell.simdata.DataServerImpl) ExportEvent(cbit.rmi.event.ExportEvent) FileNotFoundException(java.io.FileNotFoundException) ExportListener(cbit.rmi.event.ExportListener) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) DataAccessException(org.vcell.util.DataAccessException)

Example 2 with DataServerImpl

use of cbit.vcell.simdata.DataServerImpl in project vcell by virtualcell.

the class VCellServices method main.

/**
 * Starts the application.
 * @param args an array of command-line arguments
 */
public static void main(java.lang.String[] args) {
    OperatingSystemInfo.getInstance();
    if (args.length != 3 && args.length != 0) {
        System.out.println("Missing arguments: " + VCellServices.class.getName() + " [sshHost sshUser sshKeyFile] ");
        System.exit(1);
    }
    try {
        PropertyLoader.loadProperties(REQUIRED_SERVICE_PROPERTIES);
        ResourceUtil.setNativeLibraryDirectory();
        new LibraryLoaderThread(false).start();
        PythonSupport.verifyInstallation(new PythonPackage[] { PythonPackage.VTK, PythonPackage.THRIFT });
        CommandService commandService = null;
        if (args.length == 3) {
            String sshHost = args[0];
            String sshUser = args[1];
            File sshKeyFile = new File(args[2]);
            try {
                commandService = new CommandServiceSshNative(sshHost, sshUser, sshKeyFile);
                commandService.command(new String[] { "/usr/bin/env bash -c ls | head -5" });
                lg.trace("SSH Connection test passed with installed keyfile, running ls as user " + sshUser + " on " + sshHost);
            } catch (Exception e) {
                e.printStackTrace();
                try {
                    commandService = new CommandServiceSshNative(sshHost, sshUser, sshKeyFile, new File("/root"));
                    commandService.command(new String[] { "/usr/bin/env bash -c ls | head -5" });
                    lg.trace("SSH Connection test passed after installing keyfile, running ls as user " + sshUser + " on " + sshHost);
                } catch (Exception e2) {
                    e.printStackTrace();
                    throw new RuntimeException("failed to establish an ssh command connection to " + sshHost + " as user '" + sshUser + "' using key '" + sshKeyFile + "'", e);
                }
            }
            // can't make user directories, they are remote.
            AbstractSolver.bMakeUserDirs = false;
        } else {
            commandService = new CommandServiceLocal();
        }
        BatchSystemType batchSystemType = BatchSystemType.SLURM;
        HtcProxy htcProxy = null;
        switch(batchSystemType) {
            case SLURM:
                {
                    htcProxy = new SlurmProxy(commandService, PropertyLoader.getRequiredProperty(PropertyLoader.htcUser));
                    break;
                }
            default:
                {
                    throw new RuntimeException("unrecognized batch scheduling option :" + batchSystemType);
                }
        }
        int serviceOrdinal = 0;
        VCMongoMessage.serviceStartup(ServiceName.dispatch, new Integer(serviceOrdinal), args);
        // //
        // // JMX registration
        // //
        // MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        // mbs.registerMBean(new VCellServiceMXBeanImpl(), new ObjectName(VCellServiceMXBean.jmxObjectName));
        ServiceInstanceStatus serviceInstanceStatus = new ServiceInstanceStatus(VCellServerID.getSystemServerID(), ServiceType.MASTER, serviceOrdinal, ManageUtils.getHostName(), new Date(), true);
        ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory();
        KeyFactory keyFactory = conFactory.getKeyFactory();
        DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(conFactory, keyFactory);
        AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(conFactory);
        SimulationDatabase simulationDatabase = new SimulationDatabaseDirect(adminDbTopLevel, databaseServerImpl, true);
        Cachetable cacheTable = new Cachetable(MessageConstants.MINUTE_IN_MS * 20);
        DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cacheTable, new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)), new File(PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirInternalProperty, PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty))));
        ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
        // add dataJobListener
        DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, exportServiceImpl);
        VCMessagingService vcMessagingService = VCellServiceHelper.getInstance().loadService(VCMessagingService.class);
        vcMessagingService.setDelegate(new ServerMessagingDelegate());
        VCellServices vcellServices = new VCellServices(htcProxy, vcMessagingService, serviceInstanceStatus, databaseServerImpl, dataServerImpl, simulationDatabase);
        dataSetControllerImpl.addDataJobListener(vcellServices);
        exportServiceImpl.addExportListener(vcellServices);
        vcellServices.init();
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
}
Also used : Cachetable(cbit.vcell.simdata.Cachetable) DataServerImpl(cbit.vcell.simdata.DataServerImpl) ServerMessagingDelegate(cbit.vcell.message.server.ServerMessagingDelegate) HtcProxy(cbit.vcell.message.server.htc.HtcProxy) CommandService(cbit.vcell.message.server.cmd.CommandService) VCMessagingService(cbit.vcell.message.VCMessagingService) ConnectionFactory(org.vcell.db.ConnectionFactory) SimulationDatabaseDirect(cbit.vcell.message.server.dispatcher.SimulationDatabaseDirect) CommandServiceLocal(cbit.vcell.message.server.cmd.CommandServiceLocal) ServiceInstanceStatus(cbit.vcell.message.server.ServiceInstanceStatus) DatabaseServerImpl(cbit.vcell.modeldb.DatabaseServerImpl) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) KeyFactory(org.vcell.db.KeyFactory) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) SimulationDatabase(cbit.vcell.message.server.dispatcher.SimulationDatabase) LibraryLoaderThread(cbit.vcell.resource.LibraryLoaderThread) SlurmProxy(cbit.vcell.message.server.htc.slurm.SlurmProxy) VCMessagingException(cbit.vcell.message.VCMessagingException) Date(java.util.Date) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) BatchSystemType(cbit.vcell.server.HtcJobID.BatchSystemType) File(java.io.File) CommandServiceSshNative(cbit.vcell.message.server.cmd.CommandServiceSshNative)

Example 3 with DataServerImpl

use of cbit.vcell.simdata.DataServerImpl in project vcell by virtualcell.

the class SimDataServer method main.

/**
 * Starts the application.
 * @param args an array of command-line arguments
 */
public static void main(java.lang.String[] args) {
    if (args.length < 1) {
        System.out.println("Missing arguments: " + SimDataServer.class.getName() + " serviceOrdinal [EXPORTONLY] [logdir]");
        System.exit(1);
    }
    try {
        PropertyLoader.loadProperties();
        int serviceOrdinal = Integer.parseInt(args[0]);
        String logdir = null;
        boolean bExportOnly = false;
        if (args.length > 1) {
            if (args[1].equalsIgnoreCase("EXPORTONLY")) {
                bExportOnly = true;
                VCMongoMessage.serviceStartup(ServiceName.export, new Integer(serviceOrdinal), args);
                if (args.length > 2) {
                    logdir = args[2];
                }
            } else {
                VCMongoMessage.serviceStartup(ServiceName.simData, new Integer(serviceOrdinal), args);
                logdir = args[1];
            }
        }
        ServiceInstanceStatus serviceInstanceStatus = null;
        ServiceName serviceName = null;
        if (bExportOnly) {
            serviceInstanceStatus = new ServiceInstanceStatus(VCellServerID.getSystemServerID(), ServiceType.DATAEXPORT, serviceOrdinal, ManageUtils.getHostName(), new Date(), true);
            serviceName = ServiceName.export;
        } else {
            serviceInstanceStatus = new ServiceInstanceStatus(VCellServerID.getSystemServerID(), ServiceType.DATA, serviceOrdinal, ManageUtils.getHostName(), new Date(), true);
            serviceName = ServiceName.simData;
        }
        VCMongoMessage.serviceStartup(serviceName, new Integer(serviceOrdinal), args);
        // 
        // JMX registration
        // 
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        mbs.registerMBean(new VCellServiceMXBeanImpl(), new ObjectName(VCellServiceMXBean.jmxObjectName));
        Cachetable cacheTable = new Cachetable(MessageConstants.MINUTE_IN_MS * 20);
        DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cacheTable, new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)), new File(PropertyLoader.getRequiredProperty(PropertyLoader.secondarySimDataDirInternalProperty)));
        ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
        DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, exportServiceImpl);
        VCMessagingService vcMessagingService = VCellServiceHelper.getInstance().loadService(VCMessagingService.class);
        vcMessagingService.setDelegate(new ServerMessagingDelegate());
        SimDataServer simDataServer = new SimDataServer(serviceInstanceStatus, dataServerImpl, vcMessagingService, false);
        // add dataJobListener
        dataSetControllerImpl.addDataJobListener(simDataServer);
        // add export listener
        exportServiceImpl.addExportListener(simDataServer);
        simDataServer.init();
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
}
Also used : Cachetable(cbit.vcell.simdata.Cachetable) DataServerImpl(cbit.vcell.simdata.DataServerImpl) ServerMessagingDelegate(cbit.vcell.message.server.ServerMessagingDelegate) VCMessagingService(cbit.vcell.message.VCMessagingService) Date(java.util.Date) ObjectName(javax.management.ObjectName) ServiceName(cbit.vcell.mongodb.VCMongoMessage.ServiceName) VCellServiceMXBeanImpl(cbit.vcell.message.server.jmx.VCellServiceMXBeanImpl) ServiceInstanceStatus(cbit.vcell.message.server.ServiceInstanceStatus) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) File(java.io.File) MBeanServer(javax.management.MBeanServer)

Example 4 with DataServerImpl

use of cbit.vcell.simdata.DataServerImpl in project vcell by virtualcell.

the class VirtualFrapWindowManager method startExportMovie.

public ExportEvent startExportMovie(ExportSpecs exportSpecs, OutputContext outputContext, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    ExportEvent exportEvt = null;
    ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
    DataServerImpl dataServerImpl = new DataServerImpl(localWorkSpace.getDataSetControllerImpl(), exportServiceImpl);
    exportServiceImpl.addExportListener(new ExportListener() {

        public void exportMessage(ExportEvent event) {
            System.out.println(event.toString());
        }
    });
    // the last parameter denotes whether the saved file is comporessed or not.
    exportEvt = exportServiceImpl.makeRemoteFile(outputContext, LocalWorkspace.getDefaultOwner(), dataServerImpl, exportSpecs, false, clientTaskStatusSupport);
    return exportEvt;
}
Also used : DataServerImpl(cbit.vcell.simdata.DataServerImpl) ExportEvent(cbit.rmi.event.ExportEvent) ExportListener(cbit.rmi.event.ExportListener) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl)

Example 5 with DataServerImpl

use of cbit.vcell.simdata.DataServerImpl in project vcell by virtualcell.

the class IMGExporter method main.

public static void main(String[] args) throws Exception {
    if (args.length < 7) {
        System.out.println("Usage: IMGExporter username userkey simulationkey userdatadir beginTimeIndex endTimeIndex {varName1 varName2 ...}");
        System.exit(0);
    }
    String userName = args[0];
    String userKey = args[1];
    String SimulationKey = args[2];
    String primaryDirStr = args[3];
    int beginTimeIndex = Integer.valueOf(args[4]);
    int endTimeIndex = Integer.valueOf(args[5]);
    String[] varNames = new String[args.length - 6];
    if (args.length > 6) {
        for (int i = 6; i < args.length; i++) {
            varNames[i - 6] = args[i];
        }
    }
    PropertyLoader.loadProperties();
    User user = new User(userName, new KeyValue(userKey));
    VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(new KeyValue(SimulationKey), user);
    VCSimulationDataIdentifier vcdID = new VCSimulationDataIdentifier(vcSimID, 0);
    class PrintingExportServiceImpl extends ExportServiceImpl {

        public PrintingExportServiceImpl() {
            super();
        }

        @Override
        protected void fireExportEvent(ExportEvent event) {
            super.fireExportEvent(event);
            System.out.println("Event type=" + event.getEventTypeID() + " JobID=" + event.getJobID() + " progress=" + event.getProgress());
        }
    }
    ExportServiceImpl exportServiceImpl = new PrintingExportServiceImpl();
    Cachetable cachetable = new Cachetable(10 * Cachetable.minute);
    File primaryDir = new File(primaryDirStr);
    DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cachetable, primaryDir, null);
    DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, exportServiceImpl);
    double[] allTimes = dataSetControllerImpl.getDataSetTimes(vcdID);
    TimeSpecs timeSpecs = new TimeSpecs(beginTimeIndex, endTimeIndex, allTimes, ExportConstants.TIME_RANGE);
    VariableSpecs variableSpecs = new VariableSpecs(varNames, ExportConstants.VARIABLE_MULTI);
    GeometrySpecs geometrySpecs = new GeometrySpecs(null, 0, 0, ExportConstants.GEOMETRY_SLICE);
    DisplayPreferences displayPreferences = new DisplayPreferences(DisplayAdapterService.BLUERED, new Range(0, 1), DisplayAdapterService.createBlueRedSpecialColors());
    MovieSpecs movieSpecs = new MovieSpecs(// /
    1000.0, // /
    false, // /
    new DisplayPreferences[] { displayPreferences }, // /
    ExportFormat.FORMAT_JPEG, // /
    0, // /
    1, // /
    1, // /
    1, ImagePaneModel.MESH_MODE, FormatSpecificSpecs.CODEC_JPEG, 1.0f, false, FormatSpecificSpecs.PARTICLE_SELECT);
    ExportSpecs exportSpecs = new ExportSpecs(vcdID, ExportFormat.QUICKTIME, variableSpecs, timeSpecs, geometrySpecs, movieSpecs, "IMGExporterTest", null);
    exportServiceImpl.makeRemoteFile(null, user, dataServerImpl, exportSpecs);
}
Also used : Cachetable(cbit.vcell.simdata.Cachetable) DataServerImpl(cbit.vcell.simdata.DataServerImpl) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) ExportEvent(cbit.rmi.event.ExportEvent) Range(org.vcell.util.Range) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) DisplayPreferences(cbit.image.DisplayPreferences) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) File(java.io.File)

Aggregations

DataServerImpl (cbit.vcell.simdata.DataServerImpl)6 ExportServiceImpl (cbit.vcell.export.server.ExportServiceImpl)5 ExportEvent (cbit.rmi.event.ExportEvent)4 DataSetControllerImpl (cbit.vcell.simdata.DataSetControllerImpl)4 File (java.io.File)4 Cachetable (cbit.vcell.simdata.Cachetable)3 DisplayPreferences (cbit.image.DisplayPreferences)2 ExportListener (cbit.rmi.event.ExportListener)2 VCMessagingService (cbit.vcell.message.VCMessagingService)2 ServerMessagingDelegate (cbit.vcell.message.server.ServerMessagingDelegate)2 ServiceInstanceStatus (cbit.vcell.message.server.ServiceInstanceStatus)2 Date (java.util.Date)2 User (org.vcell.util.document.User)2 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 ExportFormat (cbit.vcell.export.server.ExportFormat)1 ExportSpecs (cbit.vcell.export.server.ExportSpecs)1 ImageSpecs (cbit.vcell.export.server.ImageSpecs)1 MovieSpecs (cbit.vcell.export.server.MovieSpecs)1 PLYSpecs (cbit.vcell.export.server.PLYSpecs)1 RasterSpecs (cbit.vcell.export.server.RasterSpecs)1