Examples of WatchdogService


Examples of com.sun.sgs.service.WatchdogService

        }
    }

    @Test
    public void testAssignNodeNoNodes() throws Exception {
        WatchdogService watchdogService =
                    (WatchdogService)serverNode.getWatchdogService();

        // By reporting health as YELLOW there should not be any nodes available
        // for assignment
        watchdogService.reportHealth(
                                serverNode.getDataService().getLocalNodeId(),
                                Health.YELLOW, "A");

        long nodeId = nodeMappingService.assignNode(NodeMappingService.class,
                                                    new IdentityImpl("first"));
View Full Code Here

Examples of com.sun.sgs.service.WatchdogService

        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);
    serverProxy = exporter.getProxy();
    logger.log(
        Level.CONFIG,
        "ChannelServer export successful. port:{0,number,#}", port);
      } catch (Exception e) {
    try {
        exporter.unexport();
    } catch (RuntimeException re) {
    }
    throw e;
      }

      /*
       * Check service version.
       */
      transactionScheduler.runTask(
    new AbstractKernelRunnable("CheckServiceVersion") {
        public void run() {
      checkServiceVersion(
          VERSION_KEY, MAJOR_VERSION, MINOR_VERSION);
        } },  taskOwner);
     
      /*
       * Create channel server map, keyed by node ID.  Then store
       * channel server in the channel server map.
       */
      transactionScheduler.runTask(
    new AbstractKernelRunnable("StoreChannelServerProxy") {
        public void run() {
      getChannelServerMap().put(
          Long.toString(localNodeId), serverProxy);
        } },
    taskOwner);

      /*
       * Add listeners for handling recovery and for receiving
       * notification of client session relocation and disconnection.
       */
      watchdogService.addRecoveryListener(
    new ChannelServiceRecoveryListener());

      watchdogService.addNodeListener(new ChannelServiceNodeListener());

      sessionStatusListener = new SessionStatusListener();
            sessionService.addSessionStatusListener(sessionStatusListener);

            /* Create our service profiling info and register our MBean. */
 
View Full Code Here

Examples of com.sun.sgs.service.WatchdogService

    private long chooseCoordinatorNode() {
  if (!servers.isEmpty()) {
      int numServers = servers.size();
      Long[] serverIds = servers.toArray(new Long[numServers]);
      int startIndex = random.nextInt(numServers);
      WatchdogService watchdogService =
    ChannelServiceImpl.getWatchdogService();
      for (int i = 0; i < numServers; i++) {
    int tryIndex = (startIndex + i) % numServers;
    long candidateId = serverIds[tryIndex];
    Node coordCandidate = watchdogService.getNode(candidateId);
    if (coordCandidate != null && coordCandidate.isAlive()) {
        return candidateId;
    }
      }
  }
View Full Code Here

Examples of com.sun.sgs.service.WatchdogService

  setUp(props, false, appName, protocolVersion);

  DummyClient client1 = createDummyClient("client1");
  DummyClient client2 = createDummyClient("client2");
  int port = serverNode.getAppPort();
        WatchdogService watchdog = serverNode.getWatchdogService();
  try {
      client1.connect(port).login();
      Thread.sleep(100);
            assertTrue(client1.isConnected());
            assertEquals(Health.GREEN, watchdog.getLocalNodeHealthNonTransactional());
      client2.connect(port).login();
      Thread.sleep(100);
            assertTrue(client2.isConnected());
            assertEquals(Health.YELLOW, watchdog.getLocalNodeHealthNonTransactional());
            client1.disconnect();
      Thread.sleep(100);
            assertFalse(client1.isConnected());
            assertEquals(Health.GREEN, watchdog.getLocalNodeHealthNonTransactional());
  } finally {
      client1.disconnect();
      client2.disconnect();
  }
    }
View Full Code Here

Examples of com.sun.sgs.service.WatchdogService

                "com.sun.sgs.impl.service.watchdog.timesync.interval",
                "1000");
        addNodes(appProps, 1);

        WatchdogServerImpl watchdogServer = watchdogService.getServer();
        WatchdogService remoteWatchdogService =
                        additionalNodes[0].getWatchdogService();

        // watchdog server and service should initially be sync'd
        long serverTime = watchdogServer.currentAppTimeMillis();
        long serviceTime = remoteWatchdogService.currentAppTimeMillis();
        assertTrue(checkInRange(serverTime,
                                serviceTime,
                                Constants.MAX_CLOCK_GRANULARITY));

        // force watchdog service out of sync
        Field serviceTimeOffset = getField(WatchdogServiceImpl.class,
                                           "timeOffset");
        serviceTimeOffset.set(remoteWatchdogService, 0);
        serverTime = watchdogServer.currentAppTimeMillis();
        serviceTime = remoteWatchdogService.currentAppTimeMillis();
        assertFalse(checkInRange(serverTime,
                                 serviceTime,
                                 Constants.MAX_CLOCK_GRANULARITY));

        // wait for time sync interval and verify service syncs back with server
        Thread.sleep(1000 + Constants.MAX_CLOCK_GRANULARITY);
        serverTime = watchdogServer.currentAppTimeMillis();
        serviceTime = remoteWatchdogService.currentAppTimeMillis();
        assertTrue(checkInRange(serverTime,
                                serviceTime,
                                Constants.MAX_CLOCK_GRANULARITY));
    }
View Full Code Here

Examples of com.sun.sgs.service.WatchdogService

                                TransactionProxy txnProxy)
        throws Exception
    {
        super(properties);

        WatchdogService wdog = txnProxy.getService(WatchdogService.class);
        // Create the LPA algorithm pieces
        NodeType type =
            NodeType.valueOf(
                properties.getProperty(StandardProperties.NODE_TYPE));
        ProfileCollector col =
View Full Code Here

Examples of com.sun.sgs.service.WatchdogService

        NodeType type =
            NodeType.valueOf(
                wrappedProps.getProperty(StandardProperties.NODE_TYPE));
        ProfileCollector col =
            systemRegistry.getComponent(ProfileCollector.class);
        WatchdogService wdog = txnProxy.getService(WatchdogService.class);
        if (type == NodeType.coreServerNode) {
            lpaServer = new LabelPropagationServer(col, wdog, properties);
            lpa = null;
            stats = null;
            pruneTask = null;
View Full Code Here

Examples of com.sun.sgs.service.WatchdogService

      this.nodeId = nodeId;
  }

  /** {@inheritDoc} */
  public void run() {
      WatchdogService watchdogService =
    txnProxy.getService(WatchdogService.class);
      Node node = watchdogService.getNode(nodeId);
      isAlive = node != null && node.isAlive();
  }
View Full Code Here

Examples of com.sun.sgs.service.WatchdogService

        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);
    serverProxy = exporter.getProxy();
    logger.log(
        Level.CONFIG,
        "ChannelServer export successful. port:{0,number,#}", port);
      } catch (Exception e) {
    try {
        exporter.unexport();
    } catch (RuntimeException re) {
    }
    throw e;
      }

      /*
       * Check service version.
       */
      transactionScheduler.runTask(
    new AbstractKernelRunnable("CheckServiceVersion") {
        public void run() {
      checkServiceVersion(
          VERSION_KEY, MAJOR_VERSION, MINOR_VERSION);
        } },  taskOwner);
     
      /*
       * Create channel server map, keyed by node ID.  Then store
       * channel server in the channel server map.
       */
      transactionScheduler.runTask(
    new AbstractKernelRunnable("StoreChannelServerProxy") {
        public void run() {
      getChannelServerMap().put(
          Long.toString(localNodeId), serverProxy);
        } },
    taskOwner);

      /*
       * Add listeners for handling recovery and for receiving
       * notification of client session relocation and disconnection.
       */
      watchdogService.addRecoveryListener(
    new ChannelServiceRecoveryListener());

      watchdogService.addNodeListener(new ChannelServiceNodeListener());

      sessionStatusListener = new SessionStatusListener();
            sessionService.addSessionStatusListener(sessionStatusListener);

            /* Create our service profiling info and register our MBean. */
 
View Full Code Here

Examples of com.sun.sgs.service.WatchdogService

        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);
    serverProxy = exporter.getProxy();
    logger.log(
        Level.CONFIG,
        "ChannelServer export successful. port:{0,number,#}", port);
      } catch (Exception e) {
    try {
        exporter.unexport();
    } catch (RuntimeException re) {
    }
    throw e;
      }

      /*
       * Check service version.
       */
      transactionScheduler.runTask(
    new AbstractKernelRunnable("CheckServiceVersion") {
        public void run() {
      checkServiceVersion(
          VERSION_KEY, MAJOR_VERSION, MINOR_VERSION);
        } },  taskOwner);
     
      /*
       * Create channel server map, keyed by node ID.  Then store
       * channel server in the channel server map.
       */
      transactionScheduler.runTask(
    new AbstractKernelRunnable("StoreChannelServerProxy") {
        public void run() {
      getChannelServerMap().put(
          Long.toString(localNodeId), serverProxy);
        } },
    taskOwner);

      /*
       * Add listeners for handling recovery and for receiving
       * notification of client session relocation and disconnection.
       */
      watchdogService.addRecoveryListener(
    new ChannelServiceRecoveryListener());

      watchdogService.addNodeListener(new ChannelServiceNodeListener());

      sessionStatusListener = new SessionStatusListener();
            sessionService.addSessionStatusListener(sessionStatusListener);

            /* Create our service profiling info and register our MBean. */
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.