Search in sources :

Example 1 with TransientStoreEventType

use of org.apache.drill.exec.coord.store.TransientStoreEventType in project drill by axbaretto.

the class EventDispatcher method childEvent.

@Override
public void childEvent(final CuratorFramework client, final PathChildrenCacheEvent event) throws Exception {
    final PathChildrenCacheEvent.Type original = event.getType();
    final TransientStoreEventType mapped = MAPPINGS.get(original);
    if (mapped != null) {
        // dispatch the event to listeners only if it can be mapped
        final String path = event.getData().getPath();
        final byte[] bytes = event.getData().getData();
        final V value = store.getConfig().getSerializer().deserialize(bytes);
        store.fireListeners(TransientStoreEvent.of(mapped, path, value));
    }
}
Also used : PathChildrenCacheEvent(org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent) TransientStoreEventType(org.apache.drill.exec.coord.store.TransientStoreEventType)

Example 2 with TransientStoreEventType

use of org.apache.drill.exec.coord.store.TransientStoreEventType in project drill by apache.

the class EventDispatcher method childEvent.

@Override
public void childEvent(final CuratorFramework client, final PathChildrenCacheEvent event) throws Exception {
    final PathChildrenCacheEvent.Type original = event.getType();
    final TransientStoreEventType mapped = MAPPINGS.get(original);
    if (mapped != null) {
        // dispatch the event to listeners only if it can be mapped
        final String path = event.getData().getPath();
        final byte[] bytes = event.getData().getData();
        final V value = store.getConfig().getSerializer().deserialize(bytes);
        store.fireListeners(TransientStoreEvent.of(mapped, path, value));
    }
}
Also used : PathChildrenCacheEvent(org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent) TransientStoreEventType(org.apache.drill.exec.coord.store.TransientStoreEventType)

Example 3 with TransientStoreEventType

use of org.apache.drill.exec.coord.store.TransientStoreEventType in project drill by axbaretto.

the class MapBackedStore method put.

@Override
public V put(final String key, final V value) {
    final boolean hasKey = delegate.containsKey(key);
    final V old = delegate.put(key, value);
    if (old != value) {
        final TransientStoreEventType type = hasKey ? TransientStoreEventType.UPDATE : TransientStoreEventType.CREATE;
        fireListeners(TransientStoreEvent.of(type, key, value));
    }
    return old;
}
Also used : TransientStoreEventType(org.apache.drill.exec.coord.store.TransientStoreEventType)

Example 4 with TransientStoreEventType

use of org.apache.drill.exec.coord.store.TransientStoreEventType in project drill by apache.

the class MapBackedStore method put.

@Override
public V put(final String key, final V value) {
    final boolean hasKey = delegate.containsKey(key);
    final V old = delegate.put(key, value);
    if (old != value) {
        final TransientStoreEventType type = hasKey ? TransientStoreEventType.UPDATE : TransientStoreEventType.CREATE;
        fireListeners(TransientStoreEvent.of(type, key, value));
    }
    return old;
}
Also used : TransientStoreEventType(org.apache.drill.exec.coord.store.TransientStoreEventType)

Aggregations

TransientStoreEventType (org.apache.drill.exec.coord.store.TransientStoreEventType)4 PathChildrenCacheEvent (org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent)2