@Test public void testResolveShardForPathNullCookie() { when(shardStrategy.findShard(YangInstanceIdentifier.empty())).thenReturn("foo"); final Long cookie = moduleShardBackendResolver.resolveShardForPath(YangInstanceIdentifier.empty()); Assert.assertEquals(1L, cookie.longValue()); }
Long resolveShardForPath(final YangInstanceIdentifier path) { final String shardName = actorUtils().getShardStrategyFactory().getStrategy(path).findShard(path); Long cookie = shards.get(shardName); if (cookie == null) { synchronized (this) { cookie = shards.get(shardName); if (cookie == null) { cookie = nextShard++; Builder<String, Long> builder = ImmutableBiMap.builder(); builder.putAll(shards); builder.put(shardName, cookie); shards = builder.build(); } } } return cookie; }
ModuleShardBackendResolver extends AbstractShardBackendResolver { Long resolveShardForPath(final YangInstanceIdentifier path) { final String shardName = actorUtils().getShardStrategyFactory().getStrategy(path).findShard(path); Long cookie = shards.get(shardName); if (cookie == null) { synchronized (this) { cookie = shards.get(shardName); if (cookie == null) { cookie = nextShard++; Builder<String, Long> builder = ImmutableBiMap.builder(); builder.putAll(shards); builder.put(shardName, cookie); shards = builder.build(); } } } return cookie; } }
ModuleShardBackendResolver extends AbstractShardBackendResolver { Long resolveShardForPath(final YangInstanceIdentifier path) { final String shardName = actorUtils().getShardStrategyFactory().getStrategy(path).findShard(path); Long cookie = shards.get(shardName); if (cookie == null) { synchronized (this) { cookie = shards.get(shardName); if (cookie == null) { cookie = nextShard++; Builder<String, Long> builder = ImmutableBiMap.builder(); builder.putAll(shards); builder.put(shardName, cookie); shards = builder.build(); } } } return cookie; } ModuleShardBackendResolver(final ClientIdentifier clientId, final ActorUtils actorUtils); }
ModuleShardBackendResolver extends AbstractShardBackendResolver { Long resolveShardForPath(final YangInstanceIdentifier path) { final String shardName = actorUtils().getShardStrategyFactory().getStrategy(path).findShard(path); Long cookie = shards.get(shardName); if (cookie == null) { synchronized (this) { cookie = shards.get(shardName); if (cookie == null) { cookie = nextShard++; Builder<String, Long> builder = ImmutableBiMap.builder(); builder.putAll(shards); builder.put(shardName, cookie); shards = builder.build(); } } } return cookie; } ModuleShardBackendResolver(final ClientIdentifier clientId, final ActorUtils actorUtils); @Override CompletionStage<ShardBackendInfo> getBackendInfo(final Long cookie); @Override CompletionStage<ShardBackendInfo> refreshBackendInfo(final Long cookie,
            final ShardBackendInfo staleInfo); @Override void close(); @Override String resolveCookieName(Long cookie); }
ModuleShardBackendResolver extends AbstractShardBackendResolver { Long resolveShardForPath(final YangInstanceIdentifier path) { final String shardName = actorUtils().getShardStrategyFactory().getStrategy(path).findShard(path); Long cookie = shards.get(shardName); if (cookie == null) { synchronized (this) { cookie = shards.get(shardName); if (cookie == null) { cookie = nextShard++; Builder<String, Long> builder = ImmutableBiMap.builder(); builder.putAll(shards); builder.put(shardName, cookie); shards = builder.build(); } } } return cookie; } ModuleShardBackendResolver(final ClientIdentifier clientId, final ActorUtils actorUtils); @Override CompletionStage<ShardBackendInfo> getBackendInfo(final Long cookie); @Override CompletionStage<ShardBackendInfo> refreshBackendInfo(final Long cookie,
            final ShardBackendInfo staleInfo); @Override void close(); @Override String resolveCookieName(Long cookie);  }