Package com.sun.sgs.service

Examples of com.sun.sgs.service.DataService


    @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

            this.properties = properties;
        }

        /** Starts the application, throwing an exception on failure. */
        public void run() throws Exception {
            DataService dataService =
                Kernel.proxy.getService(DataService.class);
            try {
                // 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);
                } else {
                    dataService.setServiceBinding(
                            StandardProperties.APP_LISTENER,
                            new ManagedSerializable<AppListener>(listener));
                }

                // since we created the listener, we're the first one to
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.