コード例 #1
0
  /**
   * Create Grid configuration with configured checkpoints.
   *
   * @return Grid configuration.
   * @throws GridException If configuration creation failed.
   */
  public static GridConfiguration configuration() throws GridException {
    GridConfiguration cfg = new GridConfiguration();

    cfg.setLocalHost("127.0.0.1");
    cfg.setPeerClassLoadingEnabled(true);

    GridOptimizedMarshaller marsh = new GridOptimizedMarshaller();

    marsh.setRequireSerializable(false);

    cfg.setMarshaller(marsh);

    cfg.setDeploymentSpi(new GridUriDeploymentSpi());

    GridTcpDiscoverySpi discoSpi = new GridTcpDiscoverySpi();

    GridTcpDiscoveryVmIpFinder ipFinder = new GridTcpDiscoveryVmIpFinder();

    ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));

    discoSpi.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(discoSpi);

    return cfg;
  }
コード例 #2
0
  /**
   * Test file creation.
   *
   * @throws Exception In case of exception.
   */
  public void testCreateFile() throws Exception {
    GridGgfsPath root = new GridGgfsPath("/");
    GridGgfsPath path = new GridGgfsPath("/asdf");

    long max = 100L * CFG_BLOCK_SIZE / WRITING_THREADS_CNT;

    for (long size = 0; size <= max; size = size * 15 / 10 + 1) {
      assertEquals(Collections.<GridGgfsPath>emptyList(), fs.listPaths(root));

      testCreateFile(path, size, new Random().nextInt());
    }
  }
コード例 #3
0
  /** @throws Exception If failed. */
  public void testEmptyProjections() throws Exception {
    final GridClientCompute dflt = client.compute();

    Collection<? extends GridClientNode> nodes = dflt.nodes();

    assertEquals(NODES_CNT, nodes.size());

    Iterator<? extends GridClientNode> iter = nodes.iterator();

    final GridClientCompute singleNodePrj = dflt.projection(Collections.singletonList(iter.next()));

    final GridClientNode second = iter.next();

    final GridClientPredicate<GridClientNode> noneFilter =
        new GridClientPredicate<GridClientNode>() {
          @Override
          public boolean apply(GridClientNode node) {
            return false;
          }
        };

    final GridClientPredicate<GridClientNode> targetFilter =
        new GridClientPredicate<GridClientNode>() {
          @Override
          public boolean apply(GridClientNode node) {
            return node.nodeId().equals(second.nodeId());
          }
        };

    GridTestUtils.assertThrows(
        log(),
        new Callable<Object>() {
          @Override
          public Object call() throws Exception {
            return dflt.projection(noneFilter).log(-1, -1);
          }
        },
        GridServerUnreachableException.class,
        null);

    GridTestUtils.assertThrows(
        log(),
        new Callable<Object>() {
          @Override
          public Object call() throws Exception {
            return singleNodePrj.projection(second);
          }
        },
        GridClientException.class,
        null);

    GridTestUtils.assertThrows(
        log(),
        new Callable<Object>() {
          @Override
          public Object call() throws Exception {
            return singleNodePrj.projection(targetFilter);
          }
        },
        GridClientException.class,
        null);
  }