Package com.sun.sgs.impl.sharedutil

Examples of com.sun.sgs.impl.sharedutil.PropertiesWrapper


    /* -- Other classes and methods -- */

    /** Creates an environment using the specified properties. */
    static DbEnvironment getEnvironment(Properties properties) {
        return (new PropertiesWrapper(properties)).getClassInstanceProperty(
                DataStoreImpl.ENVIRONMENT_CLASS_PROPERTY,
                "com.sun.sgs.impl.service.data.store.db.bdb.BdbEnvironment",
                DbEnvironment.class,
                new Class<?>[]{
                    String.class, Properties.class, ComponentRegistry.class,
View Full Code Here


      throw new IllegalArgumentException(
    "The " + StandardProperties.APP_NAME +
    " property must be specified");
 

        PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
        retryWaitTime = wrappedProps.getIntProperty(
                IO_TASK_WAIT_TIME_PROPERTY, DEFAULT_RETRY_WAIT_TIME, 0,
                Integer.MAX_VALUE);
        maxIoAttempts = wrappedProps.getIntProperty(
                IO_TASK_RETRIES_PROPERTY, DEFAULT_MAX_IO_ATTEMPTS, 0,
                Integer.MAX_VALUE);
 
  this.logger = logger;
  this.taskScheduler = systemRegistry.getComponent(TaskScheduler.class);
View Full Code Here

        nodeId = dataService.getLocalNodeId();
        localHandoffSpace = DS_HANDOFF_SPACE + nodeId;
        watchdogService.addRecoveryListener(this);

        // get the start delay and the length of time between hand-off checks
        PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
        handoffStart = wrappedProps.getLongProperty(HANDOFF_START_PROPERTY,
                                                    HANDOFF_START_DEFAULT);
        if (handoffStart < 0) {
            throw new IllegalStateException("Handoff Start property must " +
                                            "be non-negative");
        }
        handoffPeriod = wrappedProps.getLongProperty(HANDOFF_PERIOD_PROPERTY,
                                                     HANDOFF_PERIOD_DEFAULT);
        if (handoffPeriod < 0) {
            throw new IllegalStateException("Handoff Period property must " +
                                            "be non-negative");
        }

        // get the continue policy
        continuePolicy = wrappedProps.getClassInstanceProperty(
                CONTINUE_POLICY_PROPERTY,
                CONTINUE_POLICY_DEFAULT,
                ContinuePolicy.class, new Class[]{Properties.class,
                                                  ComponentRegistry.class,
                                                  TransactionProxy.class},
                properties, systemRegistry, txnProxy);

        // create our profiling info and register our MBean
        ProfileCollector collector =
            systemRegistry.getComponent(ProfileCollector.class);
        serviceStats = new TaskServiceStats(collector);
        try {
            collector.registerMBean(serviceStats, TaskServiceStats.MXBEAN_NAME);
        } catch (JMException e) {
            logger.logThrow(Level.CONFIG, e, "Could not register MBean");
        }

        // finally, create a timer for delaying the status votes and get
        // the delay used in submitting status votes
        statusUpdateTimer = new Timer("TaskServiceImpl Status Vote Timer");
        voteDelay = wrappedProps.getLongProperty(VOTE_DELAY_PROPERTY,
                                                 VOTE_DELAY_DEFAULT);
        if (voteDelay < 0) {
            throw new IllegalStateException("Vote Delay property must " +
                                            "be non-negative");
        }
View Full Code Here

  super(systemRegistry,
        new LoggerWrapper(Logger.getLogger(CLASSNAME)),
        new LoggerWrapper(Logger.getLogger(CLASSNAME + ".abort")));
        logger.log(Level.CONFIG, "Creating DataStoreImpl");

  PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
  String specifiedDirectory =
      wrappedProps.getProperty(DIRECTORY_PROPERTY);
  if (specifiedDirectory == null) {
      String rootDir =
    properties.getProperty(StandardProperties.APP_ROOT);
      if (rootDir == null) {
    throw new IllegalArgumentException(
        "A value for the property " + StandardProperties.APP_ROOT +
        " must be specified");
      }
      specifiedDirectory = rootDir + File.separator + DEFAULT_DIRECTORY;
  }
  /*
   * Use an absolute path to avoid problems on Windows.
   * -tjb@sun.com (02/16/2007)
   */
  directory = new File(specifiedDirectory).getAbsolutePath();
  txnInfoTable = getTxnInfoTable(TxnInfo.class);
  DbTransaction dbTxn = null;
  boolean done = false;
  try {
      File directoryFile = new File(specifiedDirectory).getAbsoluteFile();
            if (!directoryFile.exists()) {
                logger.log(Level.INFO, "Creating database directory : " +
                           directoryFile.getAbsolutePath());
                if (!directoryFile.mkdirs()) {
                    throw new DataStoreException("Unable to create database " +
                                                 "directory : " +
                                                 directoryFile.getName());
                }
      }
            env = wrappedProps.getClassInstanceProperty(
                    ENVIRONMENT_CLASS_PROPERTY,
                    DEFAULT_ENVIRONMENT_CLASS,
                    DbEnvironment.class,
                    new Class<?>[]{
                        String.class, Properties.class,
View Full Code Here

            TransactionProxy txnProxy)
  throws Exception
    {
  super(properties, systemRegistry, txnProxy, logger);
        logger.log(Level.CONFIG, "Creating ClientSessionServiceImpl");
  PropertiesWrapper wrappedProps = new PropertiesWrapper(properties)
  try {
      /*
       * Get the property for controlling session event processing
       * and connection disconnection.
       */
            writeBufferSize = wrappedProps.getIntProperty(
                WRITE_BUFFER_SIZE_PROPERTY, DEFAULT_WRITE_BUFFER_SIZE,
                8192, Integer.MAX_VALUE);
      eventsPerTxn = wrappedProps.getIntProperty(
    EVENTS_PER_TXN_PROPERTY, DEFAULT_EVENTS_PER_TXN,
    1, Integer.MAX_VALUE);
      allowNewLogin = wrappedProps.getBooleanProperty(
     ALLOW_NEW_LOGIN_PROPERTY, false);
            loginHighWater = wrappedProps.getIntProperty(
                LOGIN_HIGH_WATER_PROPERTY,
                Integer.MAX_VALUE / 2, 0, Integer.MAX_VALUE / 2);
      relocationKeyLength = wrappedProps.getIntProperty(
     RELOCATION_KEY_LENGTH_PROPERTY, DEFAULT_RELOCATION_KEY_LENGTH,
    16, Integer.MAX_VALUE);
      relocationTimeout = wrappedProps.getLongProperty(
    StandardProperties.SESSION_RELOCATION_TIMEOUT_PROPERTY,
    StandardProperties.DEFAULT_SESSION_RELOCATION_TIMEOUT,
    1000L, Long.MAX_VALUE);

            /* Export the ClientSessionServer. */
      int serverPort = wrappedProps.getIntProperty(
    SERVER_PORT_PROPERTY, DEFAULT_SERVER_PORT, 0, 65535);
      serverImpl = new SessionServerImpl();
      exporter =
    new Exporter<ClientSessionServer>(ClientSessionServer.class);
      try {
    int port = exporter.export(serverImpl, serverPort);
    serverProxy = exporter.getProxy();
    if (logger.isLoggable(Level.CONFIG)) {
        logger.log(Level.CONFIG,
                            "export successful. port:{0,number,#}", port);
    }
      } catch (Exception e) {
    try {
        exporter.unexport();
    } catch (RuntimeException re) {
    }
    throw e;
      }

      /* Get services and check service version. */
      flushContextsThread.start();
      contextFactory = new ContextFactory(txnProxy);
      watchdogService = txnProxy.getService(WatchdogService.class);
      nodeMapService = txnProxy.getService(NodeMappingService.class);
      taskService = txnProxy.getService(TaskService.class);
      localNodeId = dataService.getLocalNodeId();
      watchdogService.addRecoveryListener(
    new ClientSessionServiceRecoveryListener());
     
      transactionScheduler.runTask(
    new AbstractKernelRunnable("CheckServiceVersion") {
        public void run() {
      checkServiceVersion(
          VERSION_KEY, MAJOR_VERSION, MINOR_VERSION);
        } },  taskOwner);
     
      /* Store the ClientSessionServer proxy in the data store. */
      transactionScheduler.runTask(
    new AbstractKernelRunnable("StoreClientSessionServiceProxy") {
        public void run() {
      // TBD: this could use a BindingKeyedMap.
      dataService.setServiceBinding(
          getClientSessionServerKey(localNodeId),
          new ManagedSerializable<ClientSessionServer>(
        serverProxy));
        } },
    taskOwner);

      /* Register the identity relocation and node mapping listeners. */
      nodeMapService.addIdentityRelocationListener(
    new IdentityRelocationListenerImpl());
      nodeMapService.addNodeMappingListener(
    new NodeMappingListenerImpl());

      /*
       * Create the protocol listener and acceptor.
       */
      protocolListener = new ProtocolListenerImpl();

      protocolAcceptor =
    wrappedProps.getClassInstanceProperty(
        PROTOCOL_ACCEPTOR_PROPERTY,
                    DEFAULT_PROTOCOL_ACCEPTOR,
        ProtocolAcceptor.class,
        new Class[] {
      Properties.class, ComponentRegistry.class,
View Full Code Here

        TransactionProxy txnProxy)
    {
        logger.log(Level.CONFIG, "Creating BdbEnvironment with directory: {0}",
                   directory);

  PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
  long cacheSize = wrappedProps.getLongProperty(
      CACHE_SIZE_PROPERTY, DEFAULT_CACHE_SIZE, MIN_CACHE_SIZE,
      Long.MAX_VALUE);
  long checkpointInterval = wrappedProps.getLongProperty(
      CHECKPOINT_INTERVAL_PROPERTY, DEFAULT_CHECKPOINT_INTERVAL);
  long checkpointSize = wrappedProps.getLongProperty(
      CHECKPOINT_SIZE_PROPERTY, DEFAULT_CHECKPOINT_SIZE);
  boolean flushToDisk = wrappedProps.getBooleanProperty(
      FLUSH_TO_DISK_PROPERTY, false);
  long txnTimeout = wrappedProps.getLongProperty(
      TransactionCoordinator.TXN_TIMEOUT_PROPERTY, -1);
  long defaultLockTimeout = (txnTimeout < 1)
      ? DEFAULT_LOCK_TIMEOUT : computeLockTimeout(txnTimeout);
  long lockTimeout = wrappedProps.getLongProperty(
      LOCK_TIMEOUT_PROPERTY, defaultLockTimeout, 1, Long.MAX_VALUE);
  /* Avoid overflow -- BDB treats 0 as unlimited */
  long lockTimeoutMicros = (lockTimeout < (Long.MAX_VALUE / 1000))
      ? lockTimeout * 1000 : 0;
  boolean removeLogs = wrappedProps.getBooleanProperty(
      REMOVE_LOGS_PROPERTY, false);
  TxnIsolationLevel txnIsolation = wrappedProps.getEnumProperty(
      TXN_ISOLATION_PROPERTY, TxnIsolationLevel.class,
      TxnIsolationLevel.SERIALIZABLE);
  switch (txnIsolation) {
  case READ_UNCOMMITTED:
      defaultTxnConfig.setReadUncommitted(true);
View Full Code Here

    public LabelPropagationServer(ProfileCollector col, WatchdogService wdog,
            Properties properties)
        throws IOException
    {
        this.wdog = wdog;
        PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
        // Retry behavior
        retryWaitTime = wrappedProps.getIntProperty(
                IO_TASK_WAIT_TIME_PROPERTY, DEFAULT_RETRY_WAIT_TIME, 0,
                Integer.MAX_VALUE);
        maxIoAttempts = wrappedProps.getIntProperty(
                IO_TASK_RETRIES_PROPERTY, DEFAULT_MAX_IO_ATTEMPTS, 0,
                Integer.MAX_VALUE);

        // Register our node listener with the watchdog service.
        wdog.addNodeListener(new NodeFailListener());
       
        int requestedPort = wrappedProps.getIntProperty(
                SERVER_PORT_PROPERTY, DEFAULT_SERVER_PORT, 0, 65535);
        // Export ourself.
        exporter = new Exporter<LPAServer>(LPAServer.class);
        exporter.export(this, SERVER_EXPORT_NAME, requestedPort);
View Full Code Here

    {

  taskCount = 0;
  profileSamples = new HashMap<String, Histogram>();

  windowSize = new PropertiesWrapper(properties).
      getIntProperty(ProfileListener.WINDOW_SIZE_PROPERTY,
                           DEFAULT_WINDOW_SIZE);
    }
View Full Code Here

     */
    public SnapshotProfileListener(Properties properties, Identity owner,
                                   ComponentRegistry registry)
        throws IOException
    {
        PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);

        int port = wrappedProps.getIntProperty(PORT_PROPERTY, DEFAULT_PORT);
        networkReporter = new NetworkReporter(port);

        long reportPeriod =
            wrappedProps.getLongProperty(PERIOD_PROPERTY, DEFAULT_PERIOD);
        handle = registry.getComponent(TaskScheduler.class).
            scheduleRecurringTask(new SnapshotRunnable(reportPeriod), owner,
                                  System.currentTimeMillis() + reportPeriod,
                                  reportPeriod);
        handle.start();
View Full Code Here

        throws Exception
    {
        super(nodeId, properties);
        this.builder = builder;
        this.wdog = wdog;
        PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
        // Retry behavior
        retryWaitTime = wrappedProps.getIntProperty(
                LabelPropagationServer.IO_TASK_WAIT_TIME_PROPERTY,
                LabelPropagationServer.DEFAULT_RETRY_WAIT_TIME, 0,
                Integer.MAX_VALUE);
        maxIoAttempts = wrappedProps.getIntProperty(
                LabelPropagationServer.IO_TASK_RETRIES_PROPERTY,
                LabelPropagationServer.DEFAULT_MAX_IO_ATTEMPTS, 0,
                Integer.MAX_VALUE);
       
        String host = wrappedProps.getProperty(SERVER_HOST_PROPERTY,
      wrappedProps.getProperty(
          StandardProperties.SERVER_HOST));
        if (host == null) {
            // None specified, use local host
            host = InetAddress.getLocalHost().getHostName();
        }
        int port = wrappedProps.getIntProperty(
                LabelPropagationServer.SERVER_PORT_PROPERTY,
                LabelPropagationServer.DEFAULT_SERVER_PORT, 0, 65535);
        // Look up our server
        Registry registry = LocateRegistry.getRegistry(host, port);
        server = (LPAServer) registry.lookup(
                         LabelPropagationServer.SERVER_EXPORT_NAME);

        // Register our node listener with the watchdog service.
        wdog.addNodeListener(new NodeFailListener());

        // Export ourselves (using an anonymous port by default), and
        // register with server.
        //
        //  TBD: Another option is to have the LPAServer collect and exchange
        // all cross node edge info, and the remote labels at the start
        // of each iteration.  That would be helpful, because then the
        // server knows when all preliminary information has been exchanged.
        // Export our client object for server callbacks.
        int clientPort = wrappedProps.getIntProperty(
                                        CLIENT_PORT_PROPERTY,
                                        DEFAULT_CLIENT_PORT, 0, 65535);
        clientExporter = new Exporter<LPAClient>(LPAClient.class);
        int exportPort = clientExporter.export(this, clientPort);
        server.register(nodeId, clientExporter.getProxy());
View Full Code Here

TOP

Related Classes of com.sun.sgs.impl.sharedutil.PropertiesWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.