Пример #1
0
  /**
   * Copy constructor.
   *
   * @param orig Copy to create this instance from.
   * @param newParams Optional array of new parameters to override the ondes from {@code orig}.
   */
  public GridifyArgumentAdapter(GridifyArgument orig, Object... newParams) {
    A.notNull(orig, "orig");

    cls = orig.getMethodClass();
    mtdName = orig.getMethodName();
    target = orig.getTarget();

    types = new Class[orig.getMethodParameterTypes().length];
    params = new Object[orig.getMethodParameters().length];

    System.arraycopy(orig.getMethodParameters(), 0, params, 0, params.length);
    System.arraycopy(orig.getMethodParameterTypes(), 0, types, 0, types.length);

    // Override parameters, if any.
    if (newParams.length > 0) {
      setMethodParameters(newParams);
    }
  }
Пример #2
0
  /**
   * Starts up grid and checks all provided values for prime.
   *
   * @param args Command line arguments, none required but if provided first one should point to the
   *     Spring XML configuration file. See {@code "examples/config/"} for configuration file
   *     examples.
   * @throws GridException If example execution failed.
   */
  public static void main(String[] args) throws GridException {
    // Starts grid.
    Grid grid = args.length == 0 ? G.start() : G.start(args[0]);

    // Values we want to check for prime.
    long[] checkVals = {32452841, 32452843, 32452847, 32452849, 236887699, 217645199};

    X.println(">>>");
    X.println(
        ">>> Starting to check the following numbers for primes: " + Arrays.toString(checkVals));

    try {
      long start = System.currentTimeMillis();

      for (long checkVal : checkVals) {
        // This method will be executed on the Grid as it is
        // annotated with @Gridify annotation.
        Long divisor = GridPrimeChecker.checkPrime(checkVal, 2, checkVal);

        // If divisor is null, then the number is prime.
        if (divisor == null) {
          X.println("Value '" + checkVal + "'is a prime number.");
        } else {
          X.println("Value '" + checkVal + "' is divisible by '" + divisor + '\'');
        }
      }

      long totalTime = System.currentTimeMillis() - start;

      X.println(">>> Total time to calculate all primes (milliseconds): " + totalTime);
      X.println(">>>");
    } finally {
      // Stops grid.
      G.stop(grid.name(), true);
    }
  }
Пример #3
0
  /**
   * @return AOP test suite.
   * @throws Exception If failed.
   */
  public static TestSuite suite() throws Exception {
    TestSuite suite = new TestSuite("Gridgain AOP Test Suite");

    // Test configuration.
    suite.addTest(new TestSuite(GridBasicAopSelfTest.class));

    suite.addTest(new TestSuite(GridSpringAopSelfTest.class));
    suite.addTest(new TestSuite(GridNonSpringAopSelfTest.class));
    suite.addTest(new TestSuite(GridifySetToXXXSpringAopSelfTest.class));
    suite.addTest(new TestSuite(GridifySetToXXXNonSpringAopSelfTest.class));
    suite.addTest(new TestSuite(GridExternalNonSpringAopSelfTest.class));

    // Examples
    System.setProperty(
        GG_OVERRIDE_MCAST_GRP, GridTestUtils.getNextMulticastGroup(GridAopSelfTestSuite.class));

    return suite;
  }