use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.
the class CacheExchangeMergeTest method checkExchanges.
/**
* @param node Node.
* @param vers Expected exchange versions.
*/
private void checkExchanges(Ignite node, long... vers) {
IgniteKernal node0 = (IgniteKernal) node;
List<AffinityTopologyVersion> expVers = new ArrayList<>();
for (long ver : vers) expVers.add(new AffinityTopologyVersion(ver));
List<AffinityTopologyVersion> doneVers = new ArrayList<>();
List<GridDhtPartitionsExchangeFuture> futs = node0.context().cache().context().exchange().exchangeFutures();
for (int i = futs.size() - 1; i >= 0; i--) {
GridDhtPartitionsExchangeFuture fut = futs.get(i);
if (fut.exchangeDone() && fut.firstEvent().type() != EVT_DISCOVERY_CUSTOM_EVT) {
AffinityTopologyVersion resVer = fut.topologyVersion();
if (resVer != null)
doneVers.add(resVer);
}
}
assertEquals(expVers, doneVers);
for (CacheGroupContext grpCtx : node0.context().cache().cacheGroups()) {
for (AffinityTopologyVersion ver : grpCtx.affinity().cachedVersions()) {
if (ver.minorTopologyVersion() > 0)
continue;
assertTrue("Unexpected version [ver=" + ver + ", exp=" + expVers + ']', expVers.contains(ver));
}
}
}
use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.
the class MarshallerContextSelfTest method testClassName.
/**
* @throws Exception If failed.
*/
public void testClassName() throws Exception {
MarshallerContextImpl marshCtx = new MarshallerContextImpl(null, null);
marshCtx.onMarshallerProcessorStarted(ctx, null);
MarshallerMappingItem item = new MarshallerMappingItem(JAVA_ID, 1, String.class.getName());
marshCtx.onMappingProposed(item);
marshCtx.onMappingAccepted(item);
try (Ignite g1 = startGrid(1)) {
marshCtx = ((IgniteKernal) g1).context().marshallerContext();
String clsName = marshCtx.getClassName(JAVA_ID, 1);
assertEquals("java.lang.String", clsName);
}
}
use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.
the class GridIoManagerBenchmark method main.
/**
* @param args Command line arguments.
*/
public static void main(String[] args) {
int threads = args.length > 0 ? Integer.parseInt(args[0]) : DFLT_THREADS;
int duration = args.length > 1 ? Integer.parseInt(args[1]) : 0;
String outputFilename = args.length > 2 ? args[2] : null;
String path = args.length > 3 ? args[3] : DFLT_CONFIG;
testHeavyMsgs = args.length > 4 && "true".equalsIgnoreCase(args[4]);
testLatency = args.length > 5 && "true".equalsIgnoreCase(args[5]);
// threads = 128;
// testLatency = true;
// testHeavyMsgs = true;
X.println("Config: " + path);
X.println("Test heavy messages: " + testHeavyMsgs);
X.println("Test latency: " + testLatency);
X.println("Threads: " + threads);
X.println("Duration: " + duration);
X.println("Output file name: " + outputFilename);
IgniteKernal g = (IgniteKernal) G.start(path);
if (g.localNode().order() > 1) {
try {
sendMessages(g, threads, duration, outputFilename);
} finally {
G.stopAll(false);
}
} else
receiveMessages(g);
}
use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.
the class IgniteExceptionInNioWorkerSelfTest method testBrokenMessage.
/**
* @throws Exception If failed.
*/
public void testBrokenMessage() throws Exception {
startGrids(GRID_CNT);
try {
IgniteKernal kernal = (IgniteKernal) ignite(0);
UUID nodeId = ignite(1).cluster().localNode().id();
// This should trigger a failure in a NIO thread.
kernal.context().io().sendToCustomTopic(nodeId, GridTopic.TOPIC_CACHE.topic("cache"), new BrokenMessage(), (byte) 0);
for (int i = 0; i < 100; i++) ignite(0).cache("cache").put(i, i);
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.
the class GridIoManagerBenchmark0 method testLatency.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("deprecation")
public void testLatency() throws Exception {
final IgniteKernal sndKernal = (IgniteKernal) grid(0);
final IgniteKernal rcvKernal = (IgniteKernal) grid(1);
final ClusterNode sndNode = sndKernal.localNode();
final ClusterNode rcvNode = rcvKernal.localNode();
final GridIoManager snd = sndKernal.context().io();
final GridIoManager rcv = rcvKernal.context().io();
final LongAdder msgCntr = new LongAdder();
final Integer topic = 1;
final Map<IgniteUuid, CountDownLatch> map = new ConcurrentHashMap<>();
rcv.addMessageListener(topic, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
try {
rcv.sendToCustomTopic(sndNode, topic, (Message) msg, PUBLIC_POOL);
} catch (IgniteCheckedException e) {
error("Failed to send message.", e);
}
}
});
snd.addMessageListener(topic, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
map.get(((GridTestMessage) msg).id()).countDown();
}
});
Timer t = new Timer("results-reporter");
t.schedule(new TimerTask() {
private long ts = System.currentTimeMillis();
@Override
public void run() {
long newTs = System.currentTimeMillis();
long qrys = msgCntr.sumThenReset();
long time = newTs - ts;
X.println("Communication benchmark [qps=" + qrys * 1000 / time + ", executed=" + qrys + ", time=" + time + ']');
ts = newTs;
}
}, 10000, 10000);
final AtomicBoolean finish = new AtomicBoolean();
IgniteInternalFuture<?> f = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
IgniteUuid msgId = IgniteUuid.randomUuid();
while (!finish.get()) {
CountDownLatch latch = new CountDownLatch(1);
map.put(msgId, latch);
snd.sendToCustomTopic(rcvNode, topic, new GridTestMessage(msgId, (String) null), PUBLIC_POOL);
latch.await();
msgCntr.increment();
}
} catch (IgniteCheckedException e) {
X.println("Message send failed", e);
} catch (InterruptedException ignored) {
// No-op.
}
return null;
}
}, 1, "send-thread");
Thread.sleep(TEST_TIMEOUT);
finish.set(true);
t.cancel();
f.get();
}
Aggregations