Package com.sun.sgs.service

Examples of com.sun.sgs.service.DataService


                          "to return true");
                }
            }
        }, taskOwner);

  DataService dataService = createDataService(serviceProps);
  final WatchdogServiceImpl watchdog =
      new WatchdogServiceImpl(serviceProps, systemRegistry, txnProxy,
            dummyShutdownCtrl);
  try {
            txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() throws Exception {
                    if (! watchdogService.isLocalNodeAlive()) {
                        fail("Expected watchdogService.isLocalNodeAlive() " +
                             "to return true");
                    }
                }
            }, taskOwner);

      watchdogService.shutdown();
      // wait for watchdog's renew to fail...
      Thread.sleep(renewTime * 4);

            txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() throws Exception {
                    if (watchdog.isLocalNodeAlive()) {
                        fail("Expected watchdogService.isLocalNodeAlive() " +
                             "to return false");
                    }
                }
            }, taskOwner);
     
  } finally {
      watchdog.shutdown();
      dataService.shutdown();
  }
    }
View Full Code Here


      fail("Expected watchdogService.isLocalNodeAlive" +
     "NonTransactional() to return true");
  }

  int port = watchdogService.getServer().getPort();
  DataService dataService = createDataService(serviceProps);
  WatchdogServiceImpl watchdog =
      new WatchdogServiceImpl(serviceProps, systemRegistry, txnProxy,
            dummyShutdownCtrl);
  try {
      if (! watchdog.isLocalNodeAliveNonTransactional()) {
    fail("Expected watchdog.isLocalNodeAliveNonTransactional() " +
         "to return true");
      }
      watchdogService.shutdown();
      // wait for watchdog's renew to fail...
      Thread.sleep(renewTime * 4);
      if (watchdog.isLocalNodeAliveNonTransactional()) {
    fail("Expected watchdog.isLocalNodeAliveNonTransactional() " +
         "to return false");
      }
     
  } finally {
      dataService.shutdown();
      watchdog.shutdown();
  }
    }
View Full Code Here

      new HashMap<WatchdogServiceImpl, WatchdogInfo>();
  try {
      for (int i = 0; i < 5; i++) {
    Properties props = SgsTestNode.getDefaultProperties(
        "TestWatchdogServiceImpl", serverNode, null);
    DataService dataService = createDataService(props);
    WatchdogServiceImpl watchdog =
        new WatchdogServiceImpl(props, systemRegistry, txnProxy,
              dummyShutdownCtrl);
    DummyNodeListener listener = new DummyNodeListener();
    watchdog.addNodeListener(listener);
    watchdogMap.put(
        watchdog, new WatchdogInfo(listener, dataService));
      }
 
      // shutdown watchdog server
      watchdogService.shutdown();

      Thread.sleep(renewTime * 4);

      for (WatchdogServiceImpl watchdog : watchdogMap.keySet()) {
    WatchdogInfo info = watchdogMap.get(watchdog);
    DummyNodeListener listener = info.listener;
    DataService dataService = info.dataService;
    Set<Node> nodes = listener.getFailedNodes();
    System.err.println(
        "failedNodes for " + dataService.getLocalNodeId() +
        ": " + nodes);
    if (nodes.size() != 6) {
        fail("Expected 6 failed nodes, got " + nodes.size());
    }
    for (Node node : nodes) {
View Full Code Here

    @Test(expected = IllegalStateException.class)
    public void testAddRecoveryListenerServiceShuttingDown()
  throws Exception
    {
  DataService dataService = createDataService(serviceProps);
  WatchdogServiceImpl watchdog = new WatchdogServiceImpl(
      serviceProps, systemRegistry, txnProxy, dummyShutdownCtrl);
  watchdog.shutdown();
  watchdog.addRecoveryListener(new DummyRecoveryListener());
  dataService.shutdown();
    }
View Full Code Here

    @Test public void testReportLocalFailure() throws Exception {
  final String appName = "TestReportFailure";

  // Create a dummy shutdown controller to log calls to the shutdown
  // method. NOTE: The controller does not actually shutdown the node
  DataService dataService = createDataService(serviceProps);
  WatchdogServiceImpl watchdogService =
      new WatchdogServiceImpl(serviceProps, systemRegistry,
            txnProxy, dummyShutdownCtrl);

  // Report a failure, which should shutdown the node
  watchdogService.reportFailure(dataService.getLocalNodeId(),
              appName);

  // Node should not be alive since we reported a failure
  try {
      assertFalse(watchdogService.isLocalNodeAliveNonTransactional());
  } catch (Exception e) {
      fail("Not expecting an Exception: " + e.getLocalizedMessage());
  }
           
  // The shutdown controller should be incremented as a result of the
  // failure being reported
  assertEquals(1, dummyShutdownCtrl.getShutdownCount());
  watchdogService.shutdown();
  dataService.shutdown();
    }
View Full Code Here

    private WatchdogAndData createWatchdog(RecoveryListener listener)
  throws Exception
    {
  Properties props = SgsTestNode.getDefaultProperties(
      "TestWatchdogServiceImpl", serverNode, null);
  DataService data = createDataService(props);
  WatchdogServiceImpl watchdog =
      new WatchdogServiceImpl(props, systemRegistry, txnProxy,
            dummyShutdownCtrl);
  watchdog.addRecoveryListener(listener);
  watchdog.ready();
  System.err.println("Created node (" + data.getLocalNodeId() + ")");
  return new WatchdogAndData(watchdog, data);
    }
View Full Code Here

     * @param  props the configuration properties for creating the service
     * @return  the new data service
     * @throws  Exception if a problem occurs when creating the service
     */
    private DataService createDataService(Properties props) throws Exception {
  DataService dataService =
      new DataServiceImpl(props, systemRegistry, txnProxy);
  ComponentRegistry services =
      new SingletonComponentRegistry(dataService);
  ComponentRegistry managers =
      new SingletonComponentRegistry(
View Full Code Here

                DEFAULT_RETRY_WAIT_TIME, 0, Integer.MAX_VALUE);
        maxIoAttempts = wrappedProps.getIntProperty(
                AbstractService.IO_TASK_RETRIES_PROPERTY,
                DEFAULT_MAX_IO_ATTEMPTS, 0, Integer.MAX_VALUE);

        DataService dataService = txnProxy.getService(DataService.class);
        localNodeId = dataService.getLocalNodeId();

        NodeType nodeType =
                wrappedProps.getEnumProperty(StandardProperties.NODE_TYPE,
                                             NodeType.class,
                                             NodeType.singleNode);
View Full Code Here

            lpa = null;
            pruneTask = null;
            stats = null;
        } else if (type == NodeType.appNode) {
            lpaServer = null;
            DataService dataService = txnProxy.getService(DataService.class);
            long nodeId = dataService.getLocalNodeId();
            lpa = new LabelPropagation(this, wdog, nodeId, properties);

            // TODO: Register ourselves with the data servce as a listener
            // for conflict info.
View Full Code Here

            lpa = null;
            stats = null;
            pruneTask = null;
        } else if (type == NodeType.appNode) {
            lpaServer = null;
            DataService dataService = txnProxy.getService(DataService.class);
            long nodeId = dataService.getLocalNodeId();      
            lpa = new LabelPropagation(this, wdog, nodeId, properties);

            // TODO: Register ourselves with the data servce as a listener
            // for conflict info.
View Full Code Here

TOP

Related Classes of com.sun.sgs.service.DataService

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.