当前位置: 首页>>代码示例>>Java>>正文


Java Change类代码示例

本文整理汇总了Java中org.onosproject.event.Change的典型用法代码示例。如果您正苦于以下问题:Java Change类的具体用法?Java Change怎么用?Java Change使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Change类属于org.onosproject.event包,在下文中一共展示了Change类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSessionEnd

import org.onosproject.event.Change; //导入依赖的package包/类
private void onSessionEnd(ServerSession session) {
    Commit<? extends AtomixLeaderElectorCommands.Listen> listener = listeners.remove(session.id());
    if (listener != null) {
        listener.close();
    }
    Set<String> topics = elections.keySet();
    List<Change<Leadership>> changes = Lists.newArrayList();
    topics.forEach(topic -> {
        Leadership oldLeadership = leadership(topic);
        elections.compute(topic, (k, v) -> v.cleanup(session, termCounter(topic)::incrementAndGet));
        Leadership newLeadership = leadership(topic);
        if (!Objects.equal(oldLeadership, newLeadership)) {
            changes.add(new Change<>(oldLeadership, newLeadership));
        }
    });
    notifyLeadershipChanges(changes);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:AtomixLeaderElectorState.java

示例2: addChangeListener

import org.onosproject.event.Change; //导入依赖的package包/类
@Override
public synchronized CompletableFuture<Void> addChangeListener(Consumer<Change<Leadership>> consumer) {
    if (leadershipChangeListeners.isEmpty()) {
        return client.submit(new Listen()).thenRun(() -> leadershipChangeListeners.add(consumer));
    } else {
        leadershipChangeListeners.add(consumer);
        return CompletableFuture.completedFuture(null);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:AtomixLeaderElector.java

示例3: removeChangeListener

import org.onosproject.event.Change; //导入依赖的package包/类
@Override
public synchronized CompletableFuture<Void> removeChangeListener(Consumer<Change<Leadership>> consumer) {
    if (leadershipChangeListeners.remove(consumer) && leadershipChangeListeners.isEmpty()) {
        return client.submit(new Unlisten()).thenApply(v -> null);
    }
    return CompletableFuture.completedFuture(null);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:AtomixLeaderElector.java

示例4: notifyLeadershipChanges

import org.onosproject.event.Change; //导入依赖的package包/类
private void notifyLeadershipChanges(List<Change<Leadership>> changes) {
    if (changes.isEmpty()) {
        return;
    }
    listeners.values()
             .forEach(listener -> listener.session()
                                          .publish(AtomixLeaderElector.CHANGE_SUBJECT, changes));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:AtomixLeaderElectorState.java

示例5: accept

import org.onosproject.event.Change; //导入依赖的package包/类
@Override
public void accept(Change<Leadership> change) {
    synchronized (this) {
        if (pendingFuture != null) {
            pendingFuture.complete(change);
            pendingFuture = null;
        } else {
            eventQueue.add(change);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:AtomixLeaderElectorTest.java

示例6: nextEvent

import org.onosproject.event.Change; //导入依赖的package包/类
public CompletableFuture<Change<Leadership>> nextEvent() {
    synchronized (this) {
        if (eventQueue.isEmpty()) {
            if (pendingFuture == null) {
                pendingFuture = new CompletableFuture<>();
            }
            return pendingFuture;
        } else {
            return CompletableFuture.completedFuture(eventQueue.poll());
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:AtomixLeaderElectorTest.java

示例7: addChangeListener

import org.onosproject.event.Change; //导入依赖的package包/类
@Override
public synchronized CompletableFuture<Void> addChangeListener(Consumer<Change<Leadership>> consumer) {
    if (leadershipChangeListeners.isEmpty()) {
        return proxy.invoke(ADD_LISTENER).thenRun(() -> leadershipChangeListeners.add(consumer));
    } else {
        leadershipChangeListeners.add(consumer);
        return CompletableFuture.completedFuture(null);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:10,代码来源:AtomixLeaderElector.java

示例8: removeChangeListener

import org.onosproject.event.Change; //导入依赖的package包/类
@Override
public synchronized CompletableFuture<Void> removeChangeListener(Consumer<Change<Leadership>> consumer) {
    if (leadershipChangeListeners.remove(consumer) && leadershipChangeListeners.isEmpty()) {
        return proxy.invoke(REMOVE_LISTENER).thenApply(v -> null);
    }
    return CompletableFuture.completedFuture(null);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:8,代码来源:AtomixLeaderElector.java

示例9: onSessionEnd

import org.onosproject.event.Change; //导入依赖的package包/类
private void onSessionEnd(RaftSession session) {
    listeners.remove(session.sessionId().id());
    Set<String> topics = elections.keySet();
    List<Change<Leadership>> changes = Lists.newArrayList();
    topics.forEach(topic -> {
        Leadership oldLeadership = leadership(topic);
        elections.compute(topic, (k, v) -> v.cleanup(topic, session, termCounter(topic)::incrementAndGet));
        Leadership newLeadership = leadership(topic);
        if (!Objects.equal(oldLeadership, newLeadership)) {
            changes.add(new Change<>(oldLeadership, newLeadership));
        }
    });
    notifyLeadershipChanges(changes);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:15,代码来源:AtomixLeaderElectorService.java

示例10: addChangeListener

import org.onosproject.event.Change; //导入依赖的package包/类
@Override
public void addChangeListener(Consumer<Change<Leadership>> consumer) {
    complete(asyncElector.addChangeListener(consumer));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:DefaultLeaderElector.java

示例11: removeChangeListener

import org.onosproject.event.Change; //导入依赖的package包/类
@Override
public void removeChangeListener(Consumer<Change<Leadership>> consumer) {
    complete(asyncElector.removeChangeListener(consumer));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:DefaultLeaderElector.java

示例12: handleEvent

import org.onosproject.event.Change; //导入依赖的package包/类
private void handleEvent(List<Change<Leadership>> changes) {
    changes.forEach(change -> leadershipChangeListeners.forEach(l -> l.accept(change)));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:4,代码来源:AtomixLeaderElector.java

示例13: notifyLeadershipChange

import org.onosproject.event.Change; //导入依赖的package包/类
private void notifyLeadershipChange(Leadership previousLeadership, Leadership newLeadership) {
    notifyLeadershipChanges(Lists.newArrayList(new Change<>(previousLeadership, newLeadership)));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:4,代码来源:AtomixLeaderElectorState.java

示例14: getSerializer

import org.onosproject.event.Change; //导入依赖的package包/类
public static Serializer getSerializer() {
    Serializer serializer = new Serializer();
    TypeSerializerFactory factory =
            new DefaultCatalystTypeSerializerFactory(
                    org.onosproject.store.service.Serializer.using(Arrays.asList((KryoNamespaces.API)),
                            MapEntryUpdateResult.class,
                            MapEntryUpdateResult.Status.class,
                            Transaction.State.class,
                            PrepareResult.class,
                            CommitResult.class,
                            RollbackResult.class));
    // ONOS classes
    serializer.register(Change.class, factory);
    serializer.register(Leader.class, factory);
    serializer.register(Leadership.class, factory);
    serializer.register(NodeId.class, factory);
    serializer.register(Match.class, factory);
    serializer.register(MapEntryUpdateResult.class, factory);
    serializer.register(MapEntryUpdateResult.Status.class, factory);
    serializer.register(Transaction.State.class, factory);
    serializer.register(PrepareResult.class, factory);
    serializer.register(CommitResult.class, factory);
    serializer.register(RollbackResult.class, factory);
    serializer.register(TransactionId.class, factory);
    serializer.register(MapUpdate.class, factory);
    serializer.register(MapUpdate.Type.class, factory);
    serializer.register(MapTransaction.class, factory);
    serializer.register(Versioned.class, factory);
    serializer.register(MapEvent.class, factory);
    serializer.register(Maps.immutableEntry("a", "b").getClass(), factory);

    serializer.resolve(new LongCommands.TypeResolver());
    serializer.resolve(new AtomixConsistentMapCommands.TypeResolver());
    serializer.resolve(new AtomixLeaderElectorCommands.TypeResolver());
    serializer.resolve(new ResourceManagerTypeResolver());

    serializer.registerClassLoader(AtomixConsistentMapFactory.class)
              .registerClassLoader(AtomixLeaderElectorFactory.class);

    return serializer;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:42,代码来源:CatalystSerializers.java

示例15: addChangeListener

import org.onosproject.event.Change; //导入依赖的package包/类
@Override
public CompletableFuture<Void> addChangeListener(Consumer<Change<Leadership>> listener) {
    return CompletableFuture.allOf(getLeaderElectors().stream()
                                                      .map(map -> map.addChangeListener(listener))
                                                      .toArray(CompletableFuture[]::new));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:PartitionedAsyncLeaderElector.java


注:本文中的org.onosproject.event.Change类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。