• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Versioned类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: activate

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Activate
public void activate() {
    tpool = Executors.newFixedThreadPool(4, groupedThreads("onos/flobj-notifier", "%d", log));
    eventQ = new LinkedBlockingQueue<ObjectiveEvent>();
    tpool.execute(new FlowObjectiveNotifier());
    nextGroups = storageService.<Integer, byte[]>consistentMapBuilder()
            .withName("flowobjective-groups")
            .withSerializer(Serializer.using(
                    new KryoNamespace.Builder()
                            .register(byte[].class)
                            .register(Versioned.class)
                            .build("DistributedFlowObjectiveStore")))
            .build();
    nextGroups.addListener(mapListener);
    nextIds = storageService.getAtomicCounter("next-objective-counter");
    log.info("Started");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:DistributedFlowObjectiveStore.java


示例2: getAllocatedResources

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
<T> Stream<ContinuousResource> getAllocatedResources(DiscreteResourceId parent, Class<T> cls) {
    Set<ContinuousResource> children = getChildResources(parent);
    if (children.isEmpty()) {
        return Stream.of();
    }

    return children.stream()
            .filter(x -> x.id().equals(parent.child(cls)))
            // we don't use cascading simple predicates like follows to reduce accesses to consistent map
            // .filter(x -> continuousConsumers.containsKey(x.id()))
            // .filter(x -> continuousConsumers.get(x.id()) != null)
            // .filter(x -> !continuousConsumers.get(x.id()).value().allocations().isEmpty());
            .filter(resource -> {
                Versioned<ContinuousResourceAllocation> allocation = consumers.get(resource.id());
                if (allocation == null) {
                    return false;
                }
                return !allocation.value().allocations().isEmpty();
            });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:ConsistentContinuousResourceSubStore.java


示例3: activate

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Activate
public void activate() {
    String localIp = getSiteLocalAddress();
    ControllerNode localNode =
            new DefaultControllerNode(new NodeId(localIp), IpAddress.valueOf(localIp), DEFAULT_ONOS_PORT);
    // partition 1
    Partition partition = new DefaultPartition(PartitionId.from(1), ImmutableSet.of(localNode.id()));
    ClusterMetadata metadata = new ClusterMetadata(PROVIDER_ID,
                                    "default",
                                    ImmutableSet.of(localNode),
                                    ImmutableSet.of(partition));
    long version = System.currentTimeMillis();
    cachedMetadata.set(new Versioned<>(metadata, version));
    providerRegistry.register(this);
    log.info("Started");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:DefaultClusterMetadataProvider.java


示例4: addListener

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public CompletableFuture<Void> addListener(AtomicValueEventListener<String> listener) {
    // TODO: synchronization
    if (mapEventListener == null) {
        mapEventListener = event -> {
            Versioned<byte[]> newValue = event.newValue();
            Versioned<byte[]> oldValue = event.oldValue();
            if (Objects.equals(event.key(), name)) {
                listener.event(new AtomicValueEvent<>(name,
                        newValue == null ? null : Tools.toStringUtf8(newValue.value()),
                        oldValue == null ? null : Tools.toStringUtf8(oldValue.value())));
            }
        };
        return atomixMap.addListener(mapEventListener).whenComplete((r, e) -> {
            if (e == null) {
                listeners.add(listener);
            } else {
                mapEventListener = null;
            }
        });
    } else {
        listeners.add(listener);
        return CompletableFuture.completedFuture(null);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:AtomixValue.java


示例5: CachingAsyncConsistentMap

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
/**
 * Constructor to configure cache size.
 *
 * @param backingMap a distributed, strongly consistent map for backing
 * @param cacheSize the maximum size of the cache
 */
public CachingAsyncConsistentMap(AsyncConsistentMap<K, V> backingMap, int cacheSize) {
    super(backingMap);
    cache = CacheBuilder.newBuilder()
                        .maximumSize(cacheSize)
                        .build(CacheLoader.from(CachingAsyncConsistentMap.super::get));
    cacheUpdater = event -> {
        Versioned<V> newValue = event.newValue();
        if (newValue == null) {
            cache.invalidate(event.key());
        } else {
            cache.put(event.key(), CompletableFuture.completedFuture(newValue));
        }
    };
    statusListener = status -> {
        log.debug("{} status changed to {}", this.name(), status);
        // If the status of the underlying map is SUSPENDED or INACTIVE
        // we can no longer guarantee that the cache will be in sync.
        if (status == SUSPENDED || status == INACTIVE) {
            cache.invalidateAll();
        }
    };
    super.addListener(cacheUpdater);
    super.addStatusChangeListener(statusListener);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:CachingAsyncConsistentMap.java


示例6: setDefaultContext

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public void setDefaultContext(DeviceId deviceId) {
    Versioned<Bmv2DeviceContext> previous = contexts.put(deviceId, defaultContext);
    if (mastershipService.getMasterFor(deviceId) == null) {
        // Checking for who is the master here is ugly but necessary, as this method is called by Bmv2DeviceProvider
        // prior to master election. A solution could be to use a separate leadership contest instead of the
        // mastership service.
        triggerConfigCheck(deviceId, defaultContext);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:Bmv2DeviceContextServiceImpl.java


示例7: setPermissions

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public void setPermissions(ApplicationId appId, Set<Permission> permissions) {
    AtomicBoolean permissionsChanged = new AtomicBoolean(false);
    Versioned<InternalApplicationHolder> appHolder = apps.computeIf(appId,
        v -> v != null && !Sets.symmetricDifference(v.permissions(), permissions).isEmpty(),
        (k, v) -> {
            permissionsChanged.set(true);
            return new InternalApplicationHolder(v.app(), v.state(), ImmutableSet.copyOf(permissions));
        });
    if (permissionsChanged.get()) {
        delegate.notify(new ApplicationEvent(APP_PERMISSIONS_CHANGED, appHolder.value().app()));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:DistributedApplicationStore.java


示例8: getChildResources

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
Set<DiscreteResource> getChildResources(DiscreteResourceId parent) {
    Versioned<DiscreteResources> children = childMap.get(parent);

    if (children == null) {
        return ImmutableSet.of();
    }

    return children.value().values();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:ConsistentDiscreteResourceSubStore.java


示例9: getFreeNumOfDevicePool

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public long getFreeNumOfDevicePool(DeviceId deviceId) {
    Versioned<LabelResourcePool> pool = resourcePool.get(deviceId);
    if (pool == null) {
        return 0;
    }
    return pool.value().endLabel().labelId()
            - pool.value().currentUsedMaxLabelId().labelId()
            + pool.value().releaseLabelId().size();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:DistributedLabelResourceStore.java


示例10: getAllowingRuleByDenyingRule

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public List<RuleId> getAllowingRuleByDenyingRule(RuleId denyingRuleId) {
    Versioned<List<RuleId>> allowRuleIdSet = denyRuleToAllowRule.get(denyingRuleId);
    if (allowRuleIdSet != null) {
        return allowRuleIdSet.value();
    } else {
        return null;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:DistributedAclStore.java


示例11: getResourceAllocations

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
List<ResourceAllocation> getResourceAllocations(ContinuousResourceId resource) {
    Versioned<ContinuousResourceAllocation> allocations = consumers.get(resource);
    if (allocations == null) {
        return ImmutableList.of();
    }

    return allocations.value().allocations().stream()
            .filter(x -> x.resource().id().equals(resource))
            .collect(GuavaCollectors.toImmutableList());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:ConsistentContinuousResourceSubStore.java


示例12: getAndSet

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public CompletableFuture<V> getAndSet(V value) {
    final MeteringAgent.Context newTimer = monitor.startTimer(GET_AND_SET);
    if (value == null) {
        return backingMap.remove(name)
                         .thenApply(Versioned::valueOrNull)
                         .thenApply(v -> v == null ? null : serializer.<V>decode(v))
                         .whenComplete((r, e) -> newTimer.stop(e));
    }
    return backingMap.put(name, serializer.encode(value))
                     .thenApply(Versioned::valueOrNull)
                     .thenApply(v -> v == null ? null : serializer.<V>decode(v))
                     .whenComplete((r, e) -> newTimer.stop(e));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:DefaultAsyncAtomicValue.java


示例13: listAllMapping

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public Map<HostId, IpAssignment> listAllMapping() {
    Map<HostId, IpAssignment> validMapping = new HashMap<>();
    for (Map.Entry<HostId, Versioned<IpAssignment>> entry: allocationMap.entrySet()) {
        validMapping.put(entry.getKey(), entry.getValue().value());
    }
    return validMapping;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:DistributedDhcpStore.java


示例14: get

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public V get(K key) {
    checkState(txContext.isOpen(), TX_CLOSED_ERROR);
    checkNotNull(key, ERROR_NULL_KEY);
    if (deleteSet.contains(key)) {
        return null;
    }
    V latest = writeCache.get(key);
    if (latest != null) {
        return latest;
    } else {
        Versioned<V> v = readCache.computeIfAbsent(key, k -> backingConsitentMap.get(k));
        return v != null ? v.value() : null;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:DefaultTransactionalMap.java


示例15: deactivateRequiredApps

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
private void deactivateRequiredApps(ApplicationId appId) {
    getApplication(appId).requiredApps()
                         .stream()
                         .map(this::getId)
                         .map(apps::get)
                         .map(Versioned::value)
                         .filter(a -> a.state() == ACTIVATED)
                         .forEach(a -> deactivate(a.app().id(), appId));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:DistributedApplicationStore.java


示例16: computeIfAbsent

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public CompletableFuture<Versioned<V>> computeIfAbsent(K key,
                                                       Function<? super K, ? extends V> mappingFunction) {
    final MeteringAgent.Context timer = monitor.startTimer(COMPUTE_IF_ABSENT);
    return super.computeIfAbsent(key, mappingFunction)
                .whenComplete((r, e) -> timer.stop(e));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:MeteredAsyncConsistentMap.java


示例17: deactivateDependentApps

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
private void deactivateDependentApps(ApplicationId appId) {
    apps.values()
        .stream()
        .map(Versioned::value)
        .filter(a -> a.state() == ACTIVATED)
        .filter(a -> a.app().requiredApps().contains(appId.name()))
        .forEach(a -> deactivate(a.app().id()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:DistributedApplicationStore.java


示例18: activate

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
private void activate(ApplicationId appId, boolean updateTime) {
    Versioned<InternalApplicationHolder> vAppHolder = apps.get(appId);
    if (vAppHolder != null) {
        if (updateTime) {
            updateTime(appId.name());
        }
        activateRequiredApps(vAppHolder.value().app());

        apps.computeIf(appId, v -> v != null && v.state() != ACTIVATED,
                (k, v) -> new InternalApplicationHolder(
                        v.app(), ACTIVATED, v.permissions()));

    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:DistributedApplicationStore.java


示例19: entrySet

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public CompletableFuture<Set<Entry<K1, Versioned<V1>>>> entrySet() {
    return backingMap.entrySet()
                     .thenApply(s -> s.stream()
                                      .map(e -> Maps.immutableEntry(keyDecoder.apply(e.getKey()),
                                                                    versionedValueTransform.apply(e.getValue())))
                                      .collect(Collectors.toSet()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:TranscodingAsyncConsistentMap.java


示例20: computeIf

import org.onosproject.store.service.Versioned; //导入依赖的package包/类
@Override
public CompletableFuture<Versioned<V>> computeIf(K key,
        Predicate<? super V> condition,
        BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
    return super.computeIf(key, condition, remappingFunction)
            .whenComplete((r, e) -> cache.invalidate(key));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:CachingAsyncConsistentMap.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Edge类代码示例发布时间:2022-05-22
下一篇:
Java StringCellProcessor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap