use of org.apache.ignite.internal.util.lang.GridAbsClosure in project ignite by apache.
the class GridJobExecutionLoadTestClient method warmUp.
/**
* Warms the JVM up.
*
* @param noThreads Number of threads to use.
*/
private static void warmUp(int noThreads) {
X.println("Warming up...");
final IgniteCompute rmts = g.compute(g.cluster().forRemotes());
GridLoadTestUtils.runMultithreadedInLoop(new Callable<Object>() {
@Nullable
@Override
public Object call() {
try {
rmts.execute(GridJobExecutionLoadTestTask.class, null);
} catch (IgniteException e) {
e.printStackTrace();
}
return null;
}
}, noThreads, WARM_UP_DURATION);
// Run GC on all nodes.
try {
g.compute().run(new GridAbsClosure() {
@Override
public void apply() {
System.gc();
}
});
} catch (IgniteException e) {
throw new IllegalStateException(e);
}
}
use of org.apache.ignite.internal.util.lang.GridAbsClosure in project ignite by apache.
the class GridJobExecutionLoadTestClientSemaphore method warmUp.
/**
* Warms the JVM up.
*
* @param noThreads Number of threads to use.
*/
private static void warmUp(int noThreads) {
X.println("Warming up...");
final IgniteCompute rmts = g.compute(g.cluster().forRemotes());
GridLoadTestUtils.runMultithreadedInLoop(new Callable<Object>() {
@Nullable
@Override
public Object call() {
try {
rmts.execute(GridJobExecutionLoadTestTask.class, null);
} catch (IgniteException e) {
e.printStackTrace();
}
return null;
}
}, noThreads, WARM_UP_DURATION);
// Run GC on all nodes.
try {
g.compute().run(new GridAbsClosure() {
@Override
public void apply() {
System.gc();
}
});
} catch (IgniteException e) {
throw new IllegalStateException(e);
}
}
use of org.apache.ignite.internal.util.lang.GridAbsClosure in project ignite by apache.
the class GridMergeSortLoadTest method main.
/**
* Entry point for this test. Generates an input array of random integers,
* starts the grid, and launches the job. The method then waits for job completion.
*
* @param args Program arguments.
* <ul>
* <li>
* <b>1-st argument:</b> absolute or relative path to the configuration
* file for the grid (optional).
* </li>
* <li>
* <b>2-nd argument:</b> size of the generated array (optional, default: {@code 100000}).
* </li>
* <li>
* <b>3-nd argument:</b> size of the generated array for "warm up" (optional, default: {@code 10000}).
* </li>
* </ul>
* @throws IgniteCheckedException In case of error.
* @throws IOException In case of file output error.
*/
public static void main(String[] args) throws IgniteCheckedException, IOException {
GridFileLock fileLock = GridLoadTestUtils.fileLock();
fileLock.lock();
try {
String outputFileName = args.length >= 1 ? args[0] : null;
try (Ignite g = G.start(args.length >= 2 ? args[1] : "modules/core/src/test/config/load/merge-sort-base.xml")) {
int arrRealSize = args.length > 1 ? Integer.parseInt(args[1]) : ARR_SIZE;
int arrWarmupSize = args.length > 2 ? Integer.parseInt(args[2]) : ARR_SIZE;
X.println("Test is being executed on the gird of size " + g.cluster().nodes().size() + ".");
X.println("Performing warm up sorting of int[" + arrWarmupSize + "]...");
sort(g, arrWarmupSize);
X.println("Cleaning up after warm-up...");
// Run GC on all nodes.
g.compute().broadcast(new GridAbsClosure() {
@Override
public void apply() {
System.gc();
}
});
X.println("Performing measured sorting of int[" + arrRealSize + "]...");
long execTime = sort(g, arrRealSize);
if (outputFileName != null)
GridLoadTestUtils.appendLineToFile(outputFileName, "%s,%d", GridLoadTestUtils.DATE_TIME_FORMAT.format(new Date()), execTime / 1000);
}
} finally {
fileLock.close();
}
}
Aggregations