Package com.sun.sgs.impl.sharedutil

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


            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


  throws Exception
    {
  super(properties, systemRegistry, txnProxy, logger);
        logger.log(Level.CONFIG, "Creating ChannelServiceImpl");
 
  PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);

  try {
      synchronized (ChannelServiceImpl.class) {
    if (contextMap == null) {
        contextMap = new TransactionContextMap<Context>(txnProxy);
    }
    if (collectionsFactory == null) {
        collectionsFactory =
      systemRegistry.getComponent(
          BindingKeyedCollections.class);
    }
    if (channelServerMap == null) {
        channelServerMap =
      collectionsFactory.newMap(CHANNEL_SERVER_MAP_PREFIX);
    }
      }
      contextFactory = new ContextFactory(contextMap);
      WatchdogService watchdogService =
    txnProxy.getService(WatchdogService.class);
      sessionService = txnProxy.getService(ClientSessionService.class);
      localNodeId =
    txnProxy.getService(DataService.class).getLocalNodeId();

      /*
       * Get the properties for controlling write buffer size,
       * channel event processing, and session relocation timeout
       */
            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);
      sessionRelocationTimeout = wrappedProps.getLongProperty(
    StandardProperties.SESSION_RELOCATION_TIMEOUT_PROPERTY,
    StandardProperties.DEFAULT_SESSION_RELOCATION_TIMEOUT,
    500, Long.MAX_VALUE);
     
      /*
       * Export the ChannelServer.
       */
      int serverPort = wrappedProps.getIntProperty(
    SERVER_PORT_PROPERTY, DEFAULT_SERVER_PORT, 0, 65535);
      serverImpl = new ChannelServerImpl();
      exporter = new Exporter<ChannelServer>(ChannelServer.class);
      try {
    int port = exporter.export(serverImpl, serverPort);
View Full Code Here

  throws Exception
    {
        logger.log(Level.CONFIG, "Creating DataServiceImpl");
  DataStore storeToShutdown = null;
  try {
      PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
      appName = wrappedProps.getProperty(StandardProperties.APP_NAME);
      if (appName == null) {
    throw new IllegalArgumentException(
        "The " + StandardProperties.APP_NAME +
        " property must be specified");
      } else if (systemRegistry == null) {
    throw new NullPointerException(
        "The systemRegistry argument must not be null");
      } else if (txnProxy == null) {
    throw new NullPointerException(
        "The txnProxy argument must not be null");
      }
      this.txnProxy = txnProxy;
      debugCheckInterval = wrappedProps.getIntProperty(
    DEBUG_CHECK_INTERVAL_PROPERTY, Integer.MAX_VALUE);
      detectModifications = wrappedProps.getBooleanProperty(
    DETECT_MODIFICATIONS_PROPERTY, Boolean.TRUE);
      String dataStoreClassName = wrappedProps.getProperty(
    DATA_STORE_CLASS_PROPERTY);
      optimisticWriteLocks = wrappedProps.getBooleanProperty(
    OPTIMISTIC_WRITE_LOCKS, Boolean.FALSE);
      trackStaleObjects = wrappedProps.getBooleanProperty(
    TRACK_STALE_OBJECTS_PROPERTY, Boolean.FALSE);
            NodeType nodeType =
                wrappedProps.getEnumProperty(StandardProperties.NODE_TYPE,
                                             NodeType.class,
                                             NodeType.singleNode);

      DataStore baseStore;
      if (dataStoreClassName != null) {
    baseStore = wrappedProps.getClassInstanceProperty(
        DATA_STORE_CLASS_PROPERTY, DataStore.class,
        new Class[] { Properties.class, ComponentRegistry.class,
          TransactionProxy.class },
        properties, systemRegistry, txnProxy);
    logger.log(Level.CONFIG, "Using data store {0}", baseStore);
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

  throws Exception
    {
  super(properties, systemRegistry, txnProxy, logger);
        logger.log(Level.CONFIG, "Creating ChannelServiceImpl");
 
  PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);

  try {
      synchronized (ChannelServiceImpl.class) {
    if (contextMap == null) {
        contextMap = new TransactionContextMap<Context>(txnProxy);
    }
    if (collectionsFactory == null) {
        collectionsFactory =
      systemRegistry.getComponent(
          BindingKeyedCollections.class);
    }
    if (channelServerMap == null) {
        channelServerMap =
      collectionsFactory.newMap(CHANNEL_SERVER_MAP_PREFIX);
    }
      }
      contextFactory = new ContextFactory(contextMap);
      WatchdogService watchdogService =
    txnProxy.getService(WatchdogService.class);
      sessionService = txnProxy.getService(ClientSessionService.class);
      localNodeId =
    txnProxy.getService(DataService.class).getLocalNodeId();

      /*
       * Get the properties for controlling write buffer size,
       * channel event processing, and session relocation timeout
       */
            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);
      sessionRelocationTimeout = wrappedProps.getLongProperty(
    StandardProperties.SESSION_RELOCATION_TIMEOUT_PROPERTY,
    StandardProperties.DEFAULT_SESSION_RELOCATION_TIMEOUT,
    500, Long.MAX_VALUE);
     
      /*
       * Export the ChannelServer.
       */
      int serverPort = wrappedProps.getIntProperty(
    SERVER_PORT_PROPERTY, DEFAULT_SERVER_PORT, 0, 65535);
      serverImpl = new ChannelServerImpl();
      exporter = new Exporter<ChannelServer>(ChannelServer.class);
      try {
    int port = exporter.export(serverImpl, serverPort);
View Full Code Here

        int port = Integer.parseInt(portStr);
        if (port < 0 || port > 65535) {
            throw new IllegalArgumentException("Bad port number: " + port);
        }

  PropertiesWrapper wrappedProperties = new PropertiesWrapper(properties);
  connectTimeout =
      wrappedProperties.getLongProperty(
    "connectTimeout", DEFAULT_CONNECT_TIMEOUT);
        // TODO only RELIABLE supported for now.
        TransportType transportType = TransportType.RELIABLE;

        SocketAddress socketAddress = new InetSocketAddress(host, port);
View Full Code Here

          ComponentRegistry systemRegistry,
          TransactionProxy txnProxy)
  throws Exception
    {
  super(systemRegistry, txnProxy, logger, abortLogger);
  PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
  NodeType nodeType = wrappedProps.getEnumProperty(
      StandardProperties.NODE_TYPE, NodeType.class, NodeType.singleNode);
  boolean startServer = (nodeType != NodeType.appNode);
  int callbackPort = wrappedProps.getIntProperty(
      CALLBACK_PORT_PROPERTY, DEFAULT_CALLBACK_PORT, 0, 65535);
  int cacheSize = wrappedProps.getIntProperty(
      CACHE_SIZE_PROPERTY, DEFAULT_CACHE_SIZE, MIN_CACHE_SIZE,
      Integer.MAX_VALUE);
  evictionBatchSize = wrappedProps.getIntProperty(
      EVICTION_BATCH_SIZE_PROPERTY, DEFAULT_EVICTION_BATCH_SIZE,
      1, cacheSize);
  evictionReserveSize = wrappedProps.getIntProperty(
      EVICTION_RESERVE_SIZE_PROPERTY, DEFAULT_EVICTION_RESERVE_SIZE,
      1, cacheSize);
  long txnTimeout = wrappedProps.getLongProperty(
      TXN_TIMEOUT_PROPERTY, BOUNDED_TIMEOUT_DEFAULT);
  long defaultLockTimeout =
      Math.max(1, (long) (txnTimeout * DEFAULT_LOCK_TIMEOUT_PROPORTION));
  lockTimeout = wrappedProps.getLongProperty(
      LOCK_TIMEOUT_PROPERTY, defaultLockTimeout, 1, Long.MAX_VALUE);
  maxRetry = wrappedProps.getLongProperty(
      MAX_RETRY_PROPERTY, DEFAULT_MAX_RETRY, 0, Long.MAX_VALUE);
  int numLocks = wrappedProps.getIntProperty(
      NUM_LOCKS_PROPERTY, DEFAULT_NUM_LOCKS, 1, Integer.MAX_VALUE);
  retryWait = wrappedProps.getLongProperty(
      RETRY_WAIT_PROPERTY, DEFAULT_RETRY_WAIT, 0, Long.MAX_VALUE);
  String serverHost = wrappedProps.getProperty(
      SERVER_HOST_PROPERTY,
      wrappedProps.getProperty(StandardProperties.SERVER_HOST));
  if (serverHost == null && !startServer) {
      throw new IllegalArgumentException(
    "A server host must be specified");
  }
  int serverPort = wrappedProps.getIntProperty(
      CachingDataStoreServerImpl.SERVER_PORT_PROPERTY,
      CachingDataStoreServerImpl.DEFAULT_SERVER_PORT,
      startServer ? 0 : 1,
      65535);
  int updateQueueSize = wrappedProps.getIntProperty(
      UPDATE_QUEUE_SIZE_PROPERTY, DEFAULT_UPDATE_QUEUE_SIZE,
      1, Integer.MAX_VALUE);
  checkBindings = wrappedProps.getEnumProperty(
      CHECK_BINDINGS_PROPERTY, CheckBindingsType.class,
      CheckBindingsType.NONE);
  if (logger.isLoggable(CONFIG)) {
      logger.log(
    CONFIG,
View Full Code Here

              TransactionProxy txnProxy)
  throws IOException
    {
  super(properties, systemRegistry, txnProxy,
        new LoggerWrapper(Logger.getLogger(CLASSNAME)));
  PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
  String dbEnvClass = wrappedProps.getProperty(
      ENVIRONMENT_CLASS_PROPERTY, DEFAULT_ENVIRONMENT_CLASS);
  debug = wrappedProps.getBooleanProperty(DEBUG_OUTPUT_PROPERTY, false);
  String directory = wrappedProps.getProperty(DIRECTORY_PROPERTY);
  if (directory == null) {
      String rootDir = properties.getProperty(APP_ROOT);
      if (rootDir == null) {
    throw new IllegalArgumentException(
        "A value for the property " + APP_ROOT +
        " must be specified");
      }
      directory = rootDir + File.separator + DEFAULT_DIRECTORY;
  }
  /*
   * Use an absolute path to avoid problems on Windows.
   * -tjb@sun.com (02/16/2007)
   */
  directory = new File(directory).getAbsolutePath();
  txnTimeout = wrappedProps.getLongProperty(
      TXN_TIMEOUT_PROPERTY,
      wrappedProps.getLongProperty(
    TransactionCoordinator.TXN_TIMEOUT_PROPERTY,
    BOUNDED_TIMEOUT_DEFAULT));
  long defaultLockTimeout = (txnTimeout < 1)
      ? DEFAULT_LOCK_TIMEOUT : computeLockTimeout(txnTimeout);
  long lockTimeout = wrappedProps.getLongProperty(
      LOCK_TIMEOUT_PROPERTY, defaultLockTimeout, 1, Long.MAX_VALUE);
  long maxRetry = wrappedProps.getLongProperty(
      MAX_RETRY_PROPERTY, DEFAULT_MAX_RETRY, 0, Long.MAX_VALUE);
  int numCallbackThreads = wrappedProps.getIntProperty(
      NUM_CALLBACK_THREADS_PROPERTY, DEFAULT_NUM_CALLBACK_THREADS, 1,
      Integer.MAX_VALUE);
  int numKeyMaps = wrappedProps.getIntProperty(
      NUM_KEY_MAPS_PROPERTY, DEFAULT_NUM_KEY_MAPS, 1, Integer.MAX_VALUE);
  int requestedServerPort = wrappedProps.getIntProperty(
      SERVER_PORT_PROPERTY, DEFAULT_SERVER_PORT, 0, 65535);
  int requestedUpdateQueuePort = wrappedProps.getIntProperty(
      UPDATE_QUEUE_PORT_PROPERTY, DEFAULT_UPDATE_QUEUE_PORT, 0, 65535);
  long retryWait = wrappedProps.getLongProperty(
      RETRY_WAIT_PROPERTY, DEFAULT_RETRY_WAIT, 0, Long.MAX_VALUE);
  if (logger.isLoggable(CONFIG)) {
      logger.log(
    CONFIG,
    "Creating CachingDataStoreServerImpl with properties:" +
    "\n  " + ENVIRONMENT_CLASS_PROPERTY + "=" + dbEnvClass +
    "\n  " + DEBUG_OUTPUT_PROPERTY + "=" + debug +
    "\n  " + DIRECTORY_PROPERTY + "=" + directory +
    "\n  " + LOCK_TIMEOUT_PROPERTY + "=" + lockTimeout +
    "\n  " + MAX_RETRY_PROPERTY + "=" + maxRetry +
    "\n  " + NUM_CALLBACK_THREADS_PROPERTY + "=" +
    numCallbackThreads +
    "\n  " + NUM_KEY_MAPS_PROPERTY + "=" + numKeyMaps +
    "\n  " + RETRY_WAIT_PROPERTY + "=" + retryWait +
    "\n  " + SERVER_PORT_PROPERTY + "=" + requestedServerPort +
    "\n  " + TXN_TIMEOUT_PROPERTY + "=" + txnTimeout +
    "\n  " + UPDATE_QUEUE_PORT_PROPERTY + "=" +
    requestedUpdateQueuePort);
  }
  try {
      File directoryFile = new File(directory);
      if (!directoryFile.exists()) {
    logger.log(INFO, "Creating database directory: " + directory);
    if (!directoryFile.mkdirs()) {
        throw new DataStoreException(
      "Unable to create database directory: " + directory);
    }
      }
      env = wrappedProps.getClassInstanceProperty(
    ENVIRONMENT_CLASS_PROPERTY, DEFAULT_ENVIRONMENT_CLASS,
    DbEnvironment.class,
    new Class<?>[] {
        String.class, Properties.class,
        ComponentRegistry.class, TransactionProxy.class },
View Full Code Here

             ComponentRegistry systemRegistry,
             TransactionProxy txnProxy)
  throws IOException
    {
        logger.log(Level.CONFIG, "Creating DataStoreServerImpl");
  PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
  store = new CustomDataStoreImpl(properties, systemRegistry, txnProxy);
  maxTxnTimeout = wrappedProps.getLongProperty(
      MAX_TXN_TIMEOUT_PROPERTY, DEFAULT_MAX_TXN_TIMEOUT,
      1, Long.MAX_VALUE);
  int requestedPort = wrappedProps.getIntProperty(
      PORT_PROPERTY, DEFAULT_PORT, 0, 65535);
  exporter = noRmi ?
      new SocketExporter(DataStoreServer.class) :
      new Exporter<DataStoreServer>(DataStoreServer.class);
  port = exporter.export(this, "DataStoreServer", requestedPort);
  if (requestedPort == 0) {
      logger.log(Level.INFO, "Server is using port {0,number,#}", port);
  }
  long reapDelay = wrappedProps.getLongProperty(
      REAP_DELAY_PROPERTY, DEFAULT_REAP_DELAY);
  executor = Executors.newSingleThreadScheduledExecutor(
                new NamedThreadFactory("DataStoreServer-TransactionReaper"));
  executor.scheduleAtFixedRate(
      new Runnable() {
View Full Code Here

     * Constructs a {@code NowOrLaterRetryPolicy}.
     *
     * @param properties the system properties available
     */
    public NowOrLaterRetryPolicy(Properties properties) {
        PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
        this.retryBackoffThreshold = wrappedProps.getIntProperty(
                RETRY_BACKOFF_THRESHOLD_PROPERTY,
                DEFAULT_RETRY_BACKOFF_THRESHOLD,
                1, Integer.MAX_VALUE);

        logger.log(Level.CONFIG,
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.