Package com.sun.sgs.impl.sharedutil

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


    {
  super(properties, systemRegistry, txnProxy, logger)
  logger.log(Level.CONFIG,
       "Creating ClientSessionServiceImpl properties:{0}",
       properties);
  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);

            /* 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 = watchdogService.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() {
      dataService.setServiceBinding(
          getClientSessionServerKey(localNodeId),
          new ManagedSerializable<ClientSessionServer>(
        serverProxy));
        } },
    taskOwner);

      /*
       * 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


        nodeId = watchdogService.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");
        }

        // 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(properties, systemRegistry, txnProxy,
              new LoggerWrapper(Logger.getLogger(PKG_NAME)));
       
        logger.log(Level.CONFIG,
                 "Creating NodeMappingServiceImpl properties:{0}", properties);
        PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
       
  try {
            watchdogService = txnProxy.getService(WatchdogService.class);
           
            contextFactory = new ContextFactory(txnProxy);
               
            /*
       * Check service version.
       */
      transactionScheduler.runTask(
    new AbstractKernelRunnable("CheckServiceVersion") {
        public void run() {
      checkServiceVersion(
          NodeMapUtil.VERSION_KEY,
                            NodeMapUtil.MAJOR_VERSION,
                            NodeMapUtil.MINOR_VERSION);
        } },  taskOwner);
                   
            // Find or create our server.  
            String localHost =
                    InetAddress.getLocalHost().getHostName();
            NodeType nodeType =
                wrappedProps.getEnumProperty(StandardProperties.NODE_TYPE,
                                             NodeType.class,
                                             NodeType.singleNode);
            boolean instantiateServer = nodeType != NodeType.appNode;
           
            String host;
            int port;
           
            if (instantiateServer) {
                serverImpl =
                    new NodeMappingServerImpl(properties,
                                              systemRegistry, txnProxy);
                // Use the port actually used by our server instance
                host = localHost;
                port = serverImpl.getPort();
            } else {
                serverImpl = null;
                host =
                    wrappedProps.getProperty(
      SERVER_HOST_PROPERTY,
      wrappedProps.getProperty(
          StandardProperties.SERVER_HOST));
                if (host == null) {
                    throw new IllegalArgumentException(
                                           "A server host must be specified");
                }
                port = wrappedProps.getIntProperty(
                        NodeMappingServerImpl.SERVER_PORT_PROPERTY,
                        NodeMappingServerImpl.DEFAULT_SERVER_PORT, 0, 65535);  
            }         
         
            // TODO This code assumes that the server has already been started.
            // Perhaps it'd be better to block until the server is available?
            Registry registry = LocateRegistry.getRegistry(host, port);
            server = (NodeMappingServer) registry.lookup(
                         NodeMappingServerImpl.SERVER_EXPORT_NAME);     
           
            // Export our client object for server callbacks.
            int clientPort = wrappedProps.getIntProperty(
                                        CLIENT_PORT_PROPERTY,
                                        DEFAULT_CLIENT_PORT, 0, 65535);
            changeNotifierImpl = new MapChangeNotifier();
            exporter = new Exporter<NotifyClient>(NotifyClient.class);
            clientPort = exporter.export(changeNotifierImpl, clientPort);
View Full Code Here

    txnAwareLogManager.configure(appProperties, proxy);
      }

            // create the access coordinator
            AccessCoordinatorHandle accessCoordinator =
    new PropertiesWrapper(appProperties).getClassInstanceProperty(
        ACCESS_COORDINATOR_PROPERTY,
        AccessCoordinatorHandle.class,
        new Class[] {
      Properties.class,
      TransactionProxy.class,
View Full Code Here

  super(properties, systemRegistry, txnProxy, logger);
  logger.log(Level.CONFIG,
       "Creating SimpleSgsProtocolAcceptor properties:{0}",
       properties);

  PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
  try {
            readBufferSize = wrappedProps.getIntProperty(
                READ_BUFFER_SIZE_PROPERTY, DEFAULT_READ_BUFFER_SIZE,
                MIN_READ_BUFFER_SIZE, Integer.MAX_VALUE);
      disconnectDelay = wrappedProps.getLongProperty(
    DISCONNECT_DELAY_PROPERTY, DEFAULT_DISCONNECT_DELAY,
    MIN_DISCONNECT_DELAY, Long.MAX_VALUE);
      identityManager =
    systemRegistry.getComponent(IdentityCoordinator.class);
              
            transport =
                wrappedProps.getClassInstanceProperty(
        TRANSPORT_PROPERTY, DEFAULT_TRANSPORT, Transport.class,
        new Class[] {Properties.class}, properties);
           
            if (!transport.getDelivery().equals(Delivery.RELIABLE)) {
                transport.shutdown();
View Full Code Here

                // test to see if this name if the listener is already bound...
                dataService.getServiceBinding(StandardProperties.APP_LISTENER);
            } catch (NameNotBoundException nnbe) {
                // ...if it's not, create and then bind the listener
                AppListener listener =
                    (new PropertiesWrapper(properties)).
                    getClassInstanceProperty(StandardProperties.APP_LISTENER,
                                             AppListener.class, new Class[] {});
                if (listener instanceof ManagedObject) {
                    dataService.setServiceBinding(
                            StandardProperties.APP_LISTENER, listener);
View Full Code Here

  super(properties, systemRegistry, txnProxy, logger);
 
  logger.log(
      Level.CONFIG, "Creating ChannelServiceImpl properties:{0}",
      properties);
  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 = watchdogService.getLocalNodeId();

            writeBufferSize = wrappedProps.getIntProperty(
                WRITE_BUFFER_SIZE_PROPERTY, DEFAULT_WRITE_BUFFER_SIZE,
                8192, Integer.MAX_VALUE);
      /*
       * Get the property for controlling channel event processing.
       */
      eventsPerTxn = wrappedProps.getIntProperty(
    EVENTS_PER_TXN_PROPERTY, DEFAULT_EVENTS_PER_TXN,
    1, Integer.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

                   "Creating NodeMappingServerImpl properties:{0}",
                   properties);
       
        watchdogService = txnProxy.getService(WatchdogService.class);
      
   PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
        int requestedPort = wrappedProps.getIntProperty(
                SERVER_PORT_PROPERTY, DEFAULT_SERVER_PORT, 0, 65535);
       
        String policyClassName = wrappedProps.getProperty(
    ASSIGN_POLICY_CLASS_PROPERTY);     
        if (policyClassName == null) {
            assignPolicy = new RoundRobinPolicy(properties, this);
        } else {
            assignPolicy = wrappedProps.getClassInstanceProperty(
                ASSIGN_POLICY_CLASS_PROPERTY, NodeAssignPolicy.class,
                new Class[] { Properties.class, NodeMappingServerImpl.class },
                properties, this);
        }
       
        /*
         * Check service version.
         */
        transactionScheduler.runTask(
      new AbstractKernelRunnable("CheckServiceVersion") {
                public void run() {
                    checkServiceVersion(
                        NodeMapUtil.VERSION_KEY,
                        NodeMapUtil.MAJOR_VERSION,
                        NodeMapUtil.MINOR_VERSION);
                }
        },  taskOwner);
       
        // Create and start the remove thread, which removes unused identities
        // from the map.
        long removeExpireTime = wrappedProps.getLongProperty(
                REMOVE_EXPIRE_PROPERTY, DEFAULT_REMOVE_EXPIRE_TIME,
                1, Long.MAX_VALUE);
        removeThread = new RemoveThread(removeExpireTime);
        removeThread.start();
       
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

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

        map = new HashMap<String, TaskDetail>();

        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 TaskRunnable(), owner,
                                  System.currentTimeMillis() + reportPeriod,
                                  reportPeriod);
        handle.start();
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.