當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。