/**
   * Retrieves the {@link TransactionConfigurationAttributes} for the specified {@link Class class}
   * which may optionally declare or inherit {@link TransactionConfiguration
   * @TransactionConfiguration}. If {@code @TransactionConfiguration} is not present for the
   * supplied class, the <em>default values</em> for attributes defined in
   * {@code @TransactionConfiguration} will be used instead.
   *
   * @param testContext the test context for which the configuration attributes should be retrieved
   * @return a new TransactionConfigurationAttributes instance
   */
  private TransactionConfigurationAttributes retrieveConfigurationAttributes(
      TestContext testContext) {
    if (this.configurationAttributes == null) {
      Class<?> clazz = testContext.getTestClass();
      TransactionConfiguration config = clazz.getAnnotation(TransactionConfiguration.class);
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Retrieved @TransactionConfiguration [" + config + "] for test class [" + clazz + "]");
      }

      String transactionManagerName;
      boolean defaultRollback;
      if (config != null) {
        transactionManagerName = config.transactionManager();
        defaultRollback = config.defaultRollback();
      } else {
        transactionManagerName = DEFAULT_TRANSACTION_MANAGER_NAME;
        defaultRollback = DEFAULT_DEFAULT_ROLLBACK;
      }

      TransactionConfigurationAttributes configAttributes =
          new TransactionConfigurationAttributes(transactionManagerName, defaultRollback);
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Retrieved TransactionConfigurationAttributes "
                + configAttributes
                + " for class ["
                + clazz
                + "]");
      }
      this.configurationAttributes = configAttributes;
    }
    return this.configurationAttributes;
  }
示例#2
0
  /** {@inheritDoc} */
  @Override
  public void start(BenchmarkConfiguration cfg) throws Exception {
    IgniteBenchmarkArguments args = new IgniteBenchmarkArguments();

    BenchmarkUtils.jcommander(cfg.commandLineArguments(), args, "<ignite-node>");

    IgniteConfiguration c = loadConfiguration(args.configuration());

    assert c != null;

    // Server node doesn't contains cache configuration. Driver will create dynamic cache.
    c.setCacheConfiguration();

    TransactionConfiguration tc = c.getTransactionConfiguration();

    tc.setDefaultTxConcurrency(args.txConcurrency());
    tc.setDefaultTxIsolation(args.txIsolation());

    TcpCommunicationSpi commSpi = (TcpCommunicationSpi) c.getCommunicationSpi();

    if (commSpi == null) commSpi = new TcpCommunicationSpi();

    c.setCommunicationSpi(commSpi);

    ignite = Ignition.start(c);
  }
  /** {@inheritDoc} */
  @SuppressWarnings("unchecked")
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(gridName);

    TransactionConfiguration txCfg = c.getTransactionConfiguration();

    txCfg.setDefaultTxConcurrency(txConcurrency);
    txCfg.setDefaultTxIsolation(txIsolation);
    txCfg.setTxSerializableEnabled(true);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(cacheMode());
    cc.setAtomicityMode(TRANSACTIONAL);

    cc.setSwapEnabled(false);

    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);

    cc.setEvictionPolicy(plc);
    cc.setEvictSynchronizedKeyBufferSize(1);

    cc.setEvictSynchronized(true);

    if (testStore != null) {
      cc.setCacheStoreFactory(singletonFactory(testStore));
      cc.setReadThrough(true);
      cc.setWriteThrough(true);
      cc.setLoadPreviousValue(true);
    } else cc.setCacheStoreFactory(null);

    c.setCacheConfiguration(cc);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(ipFinder);

    c.setDiscoverySpi(disco);

    return c;
  }