Exemplo n.º 1
0
 /** Setup */
 @BeforeClass
 public static void setUpClass() throws Exception {
   serverNode = new SgsTestNode("TestScalableHashSet", null, null);
   txnScheduler = serverNode.getSystemRegistry().getComponent(TransactionScheduler.class);
   taskOwner = serverNode.getProxy().getCurrentOwner();
   dataService = serverNode.getDataService();
 }
 private void doTestRead(boolean detectMods) throws Exception {
   Properties props = getNodeProps();
   props.setProperty(DataServiceImplClass + ".detect.modifications", String.valueOf(detectMods));
   props.setProperty("com.sun.sgs.txn.timeout", "10000");
   serverNode = new SgsTestNode("TestDataServicePerformance", null, props);
   final DataService service = serverNode.getDataService();
   TransactionScheduler txnScheduler =
       serverNode.getSystemRegistry().getComponent(TransactionScheduler.class);
   Identity taskOwner = serverNode.getProxy().getCurrentOwner();
   txnScheduler.runTask(
       new AbstractKernelRunnable() {
         public void run() {
           service.setBinding("counters", new Counters(items));
         }
       },
       taskOwner);
   for (int r = 0; r < repeat; r++) {
     long start = System.currentTimeMillis();
     for (int c = 0; c < count; c++) {
       txnScheduler.runTask(
           new AbstractKernelRunnable() {
             public void run() throws Exception {
               Counters counters = (Counters) service.getBinding("counters");
               for (int i = 0; i < items; i++) {
                 counters.get(i);
               }
             }
           },
           taskOwner);
     }
     long stop = System.currentTimeMillis();
     System.err.println("Time: " + (stop - start) / (float) count + " ms per transaction");
   }
 }
 protected void setUp(Properties props) throws Exception {
   serverNode = new SgsTestNode(APP_NAME, null, props);
   profileCollector = getCollector(serverNode);
   systemRegistry = serverNode.getSystemRegistry();
   txnScheduler = systemRegistry.getComponent(TransactionScheduler.class);
   taskOwner = serverNode.getProxy().getCurrentOwner();
 }
Exemplo n.º 4
0
 public void testConstructorNullLoggerWrapper() {
   try {
     new DummyService(serviceProps, serverNode.getSystemRegistry(), serverNode.getProxy(), null);
     fail("expected NullPointerException");
   } catch (NullPointerException e) {
     System.err.println(e);
   }
 }
Exemplo n.º 5
0
 public void testConstructorNullProperties() {
   try {
     new DummyService(null, serverNode.getSystemRegistry(), serverNode.getProxy(), logger);
     fail("expected NullPointerException");
   } catch (NullPointerException e) {
     System.err.println(e);
   }
 }
 /** Shut down the nodes. */
 @After
 public void tearDown() throws Exception {
   if (additionalNodes != null) {
     for (SgsTestNode node : additionalNodes) {
       if (node != null) {
         node.shutdown(false);
       }
     }
     additionalNodes = null;
   }
   serverNode.shutdown(true);
 }
  /** Test management. */
  @Before
  public void startup() throws Exception {
    Properties properties =
        SgsTestNode.getDefaultProperties("TestAccessCoordinatorImpl", null, null);

    properties.setProperty("com.sun.sgs.finalService", "DataService");
    properties.setProperty("com.sun.sgs.txn.timeout", "1000000");

    serverNode = new SgsTestNode("TestAccessCoordinatorImpl", null, properties);

    taskOwner = serverNode.getProxy().getCurrentOwner();
    txnScheduler = serverNode.getSystemRegistry().getComponent(TransactionScheduler.class);
    dataService = serverNode.getDataService();

    accessCoordinator = serverNode.getSystemRegistry().getComponent(AccessCoordinator.class);
  }
 /** Test setup. */
 @Before
 public void setUp() throws Exception {
   // Start a partial stack.  We actually don't need any services for
   // these tests, but we cannot start up additional nodes if we don't
   // have at least the core services started.
   Properties p = SgsTestNode.getDefaultProperties(APP_NAME, null, null);
   p.setProperty("com.sun.sgs.finalService", "NodeMappingService");
   setUp(p);
 }
 // need tests to check that listeners added with boolean false (addListener)
 // are not shut down, and tests for consumer profile levels being
 // independent and changable.
 @Test
 public void testLocale() throws Exception {
   Locale.setDefault(Locale.JAPANESE);
   Properties serviceProps = SgsTestNode.getDefaultProperties(APP_NAME, serverNode, null);
   serviceProps.setProperty("com.sun.sgs.impl.kernel.profile.level", "medium");
   addNodes(serviceProps, 1);
   ProfileCollector collector = getCollector(additionalNodes[0]);
   assertNotNull(collector);
   assertSame(ProfileLevel.MEDIUM, collector.getDefaultProfileLevel());
 }
 @Test
 public void testKernelLowerCaseLevel() throws Exception {
   // The profiling level is case insensitive.
   Properties serviceProps = SgsTestNode.getDefaultProperties(APP_NAME, serverNode, null);
   serviceProps.setProperty("com.sun.sgs.impl.kernel.profile.level", "medium");
   addNodes(serviceProps, 1);
   ProfileCollector collector = getCollector(additionalNodes[0]);
   assertNotNull(collector);
   assertSame(ProfileLevel.MEDIUM, collector.getDefaultProfileLevel());
 }
  @Test
  public void testKernelNoProfile() throws Exception {
    // Even if the user specifies no profiling at startup, the collector
    // must not be null.
    Properties serviceProps = SgsTestNode.getDefaultProperties(APP_NAME, serverNode, null);
    serviceProps.setProperty("com.sun.sgs.impl.kernel.profile.level", "MIN");
    addNodes(serviceProps, 1);

    ProfileCollector collector = getCollector(additionalNodes[0]);
    assertNotNull(collector);
    assertSame(ProfileLevel.MIN, collector.getDefaultProfileLevel());
  }
 /** A utility to get the properties for the node. */
 protected Properties getNodeProps() throws Exception {
   Properties props = SgsTestNode.getDefaultProperties("TestDataServicePerformance", null, null);
   props.setProperty("com.sun.sgs.finalService", "DataService");
   props.setProperty("com.sun.sgs.impl.kernel.Kernel.profile.level", "on");
   props.setProperty(
       "com.sun.sgs.impl.kernel.Kernel.profile.listeners",
       "com.sun.sgs.impl.profile.listener." + "OperationLoggingProfileOpListener");
   props.setProperty("com.sun.sgs.server.start", "false");
   props.setProperty(
       "com.sun.sgs.impl.service.data.DataServiceImpl." + "data.store.class",
       "com.sun.sgs.impl.service.data.store.DataStoreImpl");
   return props;
 }
 @Test
 public void testKernelBadProfileLevel() throws Exception {
   // The kernel won't start if a bad profile level is provided.
   Properties serviceProps = SgsTestNode.getDefaultProperties(APP_NAME, serverNode, null);
   serviceProps.setProperty("com.sun.sgs.impl.kernel.profile.level", "JUNKJUNK");
   try {
     addNodes(serviceProps, 1);
     fail("Excpected kernel to not start up");
   } catch (InvocationTargetException e) {
     Throwable t = e.getCause();
     assertEquals(
         "Expected IllegalArgumentException",
         IllegalArgumentException.class.getName(),
         t.getClass().getName());
   }
 }
  @Before
  public void setUp() throws Exception {
    serverNode = new SgsTestNode("TestNodeMappingServiceImpl", null, null);
    txnProxy = serverNode.getProxy();

    logger = Logger.getLogger("testLogger");
    // Find a parent with handlers, which we'll wrap with a transactional
    // handler.  This mimics the actions of the TransactionalLogManager.
    Logger parent = logger;
    while (parent != null) {
      parent = parent.getParent();
      if (parent.getHandlers().length != 0) {
        break;
      }
    }
    assert (parent != null);
    for (Handler h : parent.getHandlers()) {
      Handler newHandler = ctor.newInstance(txnProxy, h);
      logger.addHandler(newHandler);
      parent.removeHandler(h);
    }
    logger.setLevel(Level.FINEST);
  }
 @After
 public void shutdown() throws Exception {
   if (serverNode != null) serverNode.shutdown(true);
 }
 /** Shuts down the service. */
 protected void shutdown() throws Exception {
   serverNode.shutdown(passed);
 }
Exemplo n.º 17
0
 /** Shuts down the server node. */
 protected void tearDown() throws Exception {
   if (serverNode != null) serverNode.shutdown(true);
 }
Exemplo n.º 18
0
 private DummyService createDummyService() {
   return new DummyService(
       serviceProps, serverNode.getSystemRegistry(), serverNode.getProxy(), logger);
 }
Exemplo n.º 19
0
 /** Teardown. */
 @AfterClass
 public static void tearDownClass() throws Exception {
   serverNode.shutdown(true);
 }
 /** Returns the profile collector for a given node */
 private ProfileCollector getCollector(SgsTestNode node) throws Exception {
   return node.getSystemRegistry().getComponent(ProfileCollector.class);
 }