Search in sources :

Example 1 with CheckpointEvent

use of org.apache.ignite.events.CheckpointEvent in project ignite by apache.

the class GridCheckpointManager method record.

/**
     * @param type Event type.
     * @param key Checkpoint key.
     */
private void record(int type, String key) {
    if (ctx.event().isRecordable(type)) {
        String msg;
        if (type == EVT_CHECKPOINT_SAVED)
            msg = "Checkpoint saved";
        else if (type == EVT_CHECKPOINT_LOADED)
            msg = "Checkpoint loaded";
        else {
            assert type == EVT_CHECKPOINT_REMOVED : "Invalid event type: " + type;
            msg = "Checkpoint removed";
        }
        if (S.INCLUDE_SENSITIVE)
            msg += ": " + key;
        ctx.event().record(new CheckpointEvent(ctx.discovery().localNode(), msg, type, key));
    }
}
Also used : CheckpointEvent(org.apache.ignite.events.CheckpointEvent)

Example 2 with CheckpointEvent

use of org.apache.ignite.events.CheckpointEvent in project ignite by apache.

the class PlatformContextImpl method writeEvent.

/** {@inheritDoc} */
@Override
public void writeEvent(BinaryRawWriterEx writer, Event evt) {
    assert writer != null;
    if (evt == null) {
        writer.writeInt(-1);
        return;
    }
    EventAdapter evt0 = (EventAdapter) evt;
    if (evt0 instanceof CacheEvent) {
        writer.writeInt(2);
        writeCommonEventData(writer, evt0);
        CacheEvent event0 = (CacheEvent) evt0;
        writer.writeString(event0.cacheName());
        writer.writeInt(event0.partition());
        writer.writeBoolean(event0.isNear());
        writeNode(writer, event0.eventNode());
        writer.writeObject(event0.key());
        writer.writeObject(event0.xid());
        writer.writeObject(event0.newValue());
        writer.writeObject(event0.oldValue());
        writer.writeBoolean(event0.hasOldValue());
        writer.writeBoolean(event0.hasNewValue());
        writer.writeUuid(event0.subjectId());
        writer.writeString(event0.closureClassName());
        writer.writeString(event0.taskName());
    } else if (evt0 instanceof CacheQueryExecutedEvent) {
        writer.writeInt(3);
        writeCommonEventData(writer, evt0);
        CacheQueryExecutedEvent event0 = (CacheQueryExecutedEvent) evt0;
        writer.writeString(event0.queryType());
        writer.writeString(event0.cacheName());
        writer.writeString(event0.className());
        writer.writeString(event0.clause());
        writer.writeUuid(event0.subjectId());
        writer.writeString(event0.taskName());
    } else if (evt0 instanceof CacheQueryReadEvent) {
        writer.writeInt(4);
        writeCommonEventData(writer, evt0);
        CacheQueryReadEvent event0 = (CacheQueryReadEvent) evt0;
        writer.writeString(event0.queryType());
        writer.writeString(event0.cacheName());
        writer.writeString(event0.className());
        writer.writeString(event0.clause());
        writer.writeUuid(event0.subjectId());
        writer.writeString(event0.taskName());
        writer.writeObject(event0.key());
        writer.writeObject(event0.value());
        writer.writeObject(event0.oldValue());
        writer.writeObject(event0.row());
    } else if (evt0 instanceof CacheRebalancingEvent) {
        writer.writeInt(5);
        writeCommonEventData(writer, evt0);
        CacheRebalancingEvent event0 = (CacheRebalancingEvent) evt0;
        writer.writeString(event0.cacheName());
        writer.writeInt(event0.partition());
        writeNode(writer, event0.discoveryNode());
        writer.writeInt(event0.discoveryEventType());
        writer.writeString(event0.discoveryEventName());
        writer.writeLong(event0.discoveryTimestamp());
    } else if (evt0 instanceof CheckpointEvent) {
        writer.writeInt(6);
        writeCommonEventData(writer, evt0);
        CheckpointEvent event0 = (CheckpointEvent) evt0;
        writer.writeString(event0.key());
    } else if (evt0 instanceof DiscoveryEvent) {
        writer.writeInt(7);
        writeCommonEventData(writer, evt0);
        DiscoveryEvent event0 = (DiscoveryEvent) evt0;
        writeNode(writer, event0.eventNode());
        writer.writeLong(event0.topologyVersion());
        writeNodes(writer, event0.topologyNodes());
    } else if (evt0 instanceof JobEvent) {
        writer.writeInt(8);
        writeCommonEventData(writer, evt0);
        JobEvent event0 = (JobEvent) evt0;
        writer.writeString(event0.taskName());
        writer.writeString(event0.taskClassName());
        writer.writeObject(event0.taskSessionId());
        writer.writeObject(event0.jobId());
        writeNode(writer, event0.taskNode());
        writer.writeUuid(event0.taskSubjectId());
    } else if (evt0 instanceof TaskEvent) {
        writer.writeInt(10);
        writeCommonEventData(writer, evt0);
        TaskEvent event0 = (TaskEvent) evt0;
        writer.writeString(event0.taskName());
        writer.writeString(event0.taskClassName());
        writer.writeObject(event0.taskSessionId());
        writer.writeBoolean(event0.internal());
        writer.writeUuid(event0.subjectId());
    } else
        throw new IgniteException("Unsupported event: " + evt);
}
Also used : CacheQueryReadEvent(org.apache.ignite.events.CacheQueryReadEvent) JobEvent(org.apache.ignite.events.JobEvent) IgniteException(org.apache.ignite.IgniteException) CacheEvent(org.apache.ignite.events.CacheEvent) TaskEvent(org.apache.ignite.events.TaskEvent) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) CheckpointEvent(org.apache.ignite.events.CheckpointEvent) CacheRebalancingEvent(org.apache.ignite.events.CacheRebalancingEvent) EventAdapter(org.apache.ignite.events.EventAdapter) CacheQueryExecutedEvent(org.apache.ignite.events.CacheQueryExecutedEvent)

Example 3 with CheckpointEvent

use of org.apache.ignite.events.CheckpointEvent in project ignite by apache.

the class GridCheckpointManagerAbstractSelfTest method doTest.

/**
     * @param igniteInstanceName Ignite instance name.
     * @throws Exception If test failed.
     */
protected void doTest(String igniteInstanceName) throws Exception {
    final AtomicInteger savedCnt = new AtomicInteger();
    final AtomicInteger loadedCnt = new AtomicInteger();
    final AtomicInteger rmvCnt = new AtomicInteger();
    try {
        Ignite ignite = startGrid(igniteInstanceName);
        ignite.events().localListen(new IgnitePredicate<Event>() {

            @Override
            public boolean apply(Event evt) {
                assert evt instanceof CheckpointEvent;
                CheckpointEvent e = (CheckpointEvent) evt;
                info("Checkpoint event: " + e);
                switch(evt.type()) {
                    case EVT_CHECKPOINT_SAVED:
                        {
                            savedCnt.incrementAndGet();
                            break;
                        }
                    case EVT_CHECKPOINT_LOADED:
                        {
                            loadedCnt.incrementAndGet();
                            break;
                        }
                    case EVT_CHECKPOINT_REMOVED:
                        {
                            rmvCnt.incrementAndGet();
                            break;
                        }
                }
                return true;
            }
        }, EVT_CHECKPOINT_SAVED, EVT_CHECKPOINT_LOADED, EVT_CHECKPOINT_REMOVED);
        executeAsync(ignite.compute(), GridTestCheckpointTask.class, null).get(2 * 60 * 1000);
        assert checkCheckpointManager(ignite) : "Session IDs got stuck after task completion: " + checkpoints(ignite).sessionIds();
    } finally {
        stopGrid(igniteInstanceName);
    }
    assertEquals(8, savedCnt.get());
    assertEquals(10, loadedCnt.get());
    if ("jdbc".equals(igniteInstanceName))
        assertEquals(5, rmvCnt.get());
    else
        assertEquals(6, rmvCnt.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CheckpointEvent(org.apache.ignite.events.CheckpointEvent) Event(org.apache.ignite.events.Event) Ignite(org.apache.ignite.Ignite) CheckpointEvent(org.apache.ignite.events.CheckpointEvent)

Aggregations

CheckpointEvent (org.apache.ignite.events.CheckpointEvent)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Ignite (org.apache.ignite.Ignite)1 IgniteException (org.apache.ignite.IgniteException)1 CacheEvent (org.apache.ignite.events.CacheEvent)1 CacheQueryExecutedEvent (org.apache.ignite.events.CacheQueryExecutedEvent)1 CacheQueryReadEvent (org.apache.ignite.events.CacheQueryReadEvent)1 CacheRebalancingEvent (org.apache.ignite.events.CacheRebalancingEvent)1 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)1 Event (org.apache.ignite.events.Event)1 EventAdapter (org.apache.ignite.events.EventAdapter)1 JobEvent (org.apache.ignite.events.JobEvent)1 TaskEvent (org.apache.ignite.events.TaskEvent)1