public void testConcurrency() throws Throwable {
   DummyComponentRegistry componentRegistry = new DummyComponentRegistry();
   service = getDataService(props, componentRegistry);
   if (service instanceof ProfileProducer) {
     DummyProfileCoordinator.startProfiling(((ProfileProducer) service));
   }
   DummyTransaction txn = new DummyTransaction();
   txnProxy.setCurrentTransaction(txn);
   service.configure(componentRegistry, txnProxy);
   componentRegistry.setComponent(DataManager.class, service);
   componentRegistry.registerAppContext();
   txn.commit();
   int perThread = objects + objectsBuffer;
   /* Create objects */
   for (int t = 0; t < maxThreads; t++) {
     long startTime = System.currentTimeMillis();
     txn = new DummyTransaction();
     txnProxy.setCurrentTransaction(txn);
     int start = t * perThread;
     BigInteger block = null;
     for (int i = 0; i < perThread; i++) {
       if (startTime + 100 < System.currentTimeMillis()) {
         txn.commit();
         txn = new DummyTransaction();
         txnProxy.setCurrentTransaction(txn);
         if (i > 0) {
           service.getBinding(getObjectName(start), ModifiableObject.class);
         }
       }
       ModifiableObject object = new ModifiableObject();
       if (i == 0) {
         service.manageInNewArea(object);
       }
       service.setBinding(getObjectName(start + i), object);
       BigInteger oidBlock = service.createReference(object).getId().shiftRight(32);
       if (block == null || !block.equals(oidBlock)) {
         block = oidBlock;
         System.err.println("Thread " + t + ": init block " + block);
       }
     }
     txn.commit();
   }
   /* Warm up */
   if (repeat != 1) {
     System.err.println("Warmup:");
     runOperations(1);
   }
   /* Test */
   for (int t = threads; t <= maxThreads; t++) {
     System.err.println("Threads: " + t);
     for (int r = 0; r < repeat; r++) {
       runOperations(t);
     }
   }
 }
示例#2
0
  /** Creates a unique context setup to run tasks */
  public static DummyAbstractKernelAppContext createContext() {
    DummyComponentRegistry systemRegistry = new DummyComponentRegistry();
    DummyComponentRegistry serviceRegistry = new DummyComponentRegistry();
    DummyAbstractKernelAppContext context = new DummyAbstractKernelAppContext(serviceRegistry);

    serviceRegistry.registerAppContext();

    TaskScheduler scheduler = null;
    if (masterSchedulerProperties == null) {
      scheduler = new DummyTaskScheduler(context, false);
    } else {
      TestResourceCoordinator rc = new TestResourceCoordinator();
      systemRegistry.setComponent(TestResourceCoordinator.class, rc);
      try {
        scheduler =
            new MasterTaskScheduler(masterSchedulerProperties, rc, taskHandler, null, context);
      } catch (Exception e) {
        throw new IllegalArgumentException("Failed to create " + "master scheduler", e);
      }
    }
    systemRegistry.setComponent(TaskScheduler.class, scheduler);

    contextMap.put(context, new ContextState(systemRegistry, serviceRegistry));

    proxy.setContext(context);
    return context;
  }
示例#3
0
 public TransactionHandle createTransaction(boolean unbounded) {
   if (txnCoordinator != null) {
     return txnCoordinator.createTransaction(unbounded);
   }
   DummyTransaction txn = new DummyTransaction();
   proxy.setCurrentTransaction(txn);
   return new TestTransactionHandle(txn);
 }
 /** Initial setup */
 @BeforeClass
 public static void setUpClass() throws Exception {
   DummyAbstractKernelAppContext appContext = MinimalTestKernel.createContext();
   DummyComponentRegistry systemRegistry = MinimalTestKernel.getSystemRegistry(appContext);
   DummyComponentRegistry serviceRegistry = MinimalTestKernel.getServiceRegistry(appContext);
   dataService =
       new DataServiceImpl(
           createProperties(
               DataStoreImpl.class.getName() + ".directory",
               dbDirectory,
               StandardProperties.APP_NAME,
               "TestScalableHashMapStress"),
           systemRegistry,
           txnProxy);
   txnProxy.setComponent(DataService.class, dataService);
   serviceRegistry.setComponent(DataManager.class, dataService);
   serviceRegistry.setComponent(DataService.class, dataService);
   taskService = new TaskServiceImpl(new Properties(), systemRegistry, txnProxy);
   serviceRegistry.setComponent(TaskManager.class, taskService);
 }
 private void createTxn() {
   txn = new DummyTransaction();
   txnProxy.setCurrentTransaction(txn);
 }
 /** Creates a transaction with the default timeout. */
 private DummyTransaction createTransaction() {
   DummyTransaction txn = new DummyTransaction();
   txnProxy.setCurrentTransaction(txn);
   return txn;
 }