Пример #1
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);
  }
  /**
   * Executes example.
   *
   * @param args Command line arguments, none required.
   */
  public static void main(String[] args) {
    try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {

      System.out.println();
      System.out.println(">>> Cache star schema example started.");

      CacheConfiguration<Integer, FactPurchase> factCacheCfg =
          new CacheConfiguration<>(PARTITIONED_CACHE_NAME);

      factCacheCfg.setCacheMode(CacheMode.PARTITIONED);
      factCacheCfg.setIndexedTypes(Integer.class, FactPurchase.class);

      CacheConfiguration<Integer, Object> dimCacheCfg =
          new CacheConfiguration<>(REPLICATED_CACHE_NAME);

      dimCacheCfg.setCacheMode(CacheMode.REPLICATED);
      dimCacheCfg.setIndexedTypes(
          Integer.class, DimStore.class,
          Integer.class, DimProduct.class);

      try (IgniteCache<Integer, FactPurchase> factCache = ignite.getOrCreateCache(factCacheCfg);
          IgniteCache<Integer, Object> dimCache = ignite.getOrCreateCache(dimCacheCfg)) {
        populateDimensions(dimCache);
        populateFacts(factCache);

        queryStorePurchases();
        queryProductPurchases();
      }
    }
  }