@Test public void explicitShardMatchesShardInstance() { int shardCount = randomShardCountGreaterThanOne(); int shardInstance = randomPositiveInteger(); when(node.getShardPropertyValue()).thenReturn(String.valueOf(shardInstance)); assertTrue(router.routeNode(shardCount, shardInstance, node)); }
@Override public Boolean routeNode(int shardCount, int shardInstance, Node node) { String shardBy = node.getShardPropertyValue(); if (shardBy == null || shardBy.trim().length() == 0) { debug("Shard {}: EXPLICIT_ID routing specified but no shard id property found for node {}", shardInstance, node.getNodeRef()); return negativeReturnValue(); } try { int shardid = Integer.parseInt(shardBy.trim()); return shardid == shardInstance; } catch (NumberFormatException exception) { debug("Shard {} EXPLICIT_ID routing specified but failed to parse a shard property value ({}) for node {}", shardInstance, shardBy, node.getNodeRef()); return negativeReturnValue(); } }
ExplicitShardIdWithDynamicPropertyRouter extends ComposableDocRouter { @Override public Boolean routeNode(int shardCount, int shardInstance, Node node) { String shardBy = node.getShardPropertyValue(); if (shardBy == null || shardBy.trim().length() == 0) { debug("Shard {}: EXPLICIT_ID routing specified but no shard id property found for node {}", shardInstance, node.getNodeRef()); return negativeReturnValue(); } try { int shardid = Integer.parseInt(shardBy.trim()); return shardid == shardInstance; } catch (NumberFormatException exception) { debug("Shard {} EXPLICIT_ID routing specified but failed to parse a shard property value ({}) for node {}", shardInstance, shardBy, node.getNodeRef()); return negativeReturnValue(); } } }
ExplicitShardIdWithDynamicPropertyRouter extends ComposableDocRouter { @Override public Boolean routeNode(int shardCount, int shardInstance, Node node) { String shardBy = node.getShardPropertyValue(); if (shardBy == null || shardBy.trim().length() == 0) { debug("Shard {}: EXPLICIT_ID routing specified but no shard id property found for node {}", shardInstance, node.getNodeRef()); return negativeReturnValue(); } try { int shardid = Integer.parseInt(shardBy.trim()); return shardid == shardInstance; } catch (NumberFormatException exception) { debug("Shard {} EXPLICIT_ID routing specified but failed to parse a shard property value ({}) for node {}", shardInstance, shardBy, node.getNodeRef()); return negativeReturnValue(); } } ExplicitShardIdWithDynamicPropertyRouter();  ExplicitShardIdWithDynamicPropertyRouter(boolean isInStandaloneMode); }
ExplicitShardIdWithDynamicPropertyRouter extends ComposableDocRouter { @Override public Boolean routeNode(int shardCount, int shardInstance, Node node) { String shardBy = node.getShardPropertyValue(); if (shardBy == null || shardBy.trim().length() == 0) { debug("Shard {}: EXPLICIT_ID routing specified but no shard id property found for node {}", shardInstance, node.getNodeRef()); return negativeReturnValue(); } try { int shardid = Integer.parseInt(shardBy.trim()); return shardid == shardInstance; } catch (NumberFormatException exception) { debug("Shard {} EXPLICIT_ID routing specified but failed to parse a shard property value ({}) for node {}", shardInstance, shardBy, node.getNodeRef()); return negativeReturnValue(); } } ExplicitShardIdWithDynamicPropertyRouter();  ExplicitShardIdWithDynamicPropertyRouter(boolean isInStandaloneMode); @Override Boolean routeAcl(int shardCount, int shardInstance, Acl acl); @Override Boolean routeNode(int shardCount, int shardInstance, Node node); @Override Map<String, String> getProperties(Optional<QName> shardProperty); }
ExplicitShardIdWithDynamicPropertyRouter extends ComposableDocRouter { @Override public Boolean routeNode(int shardCount, int shardInstance, Node node) { String shardBy = node.getShardPropertyValue(); if (shardBy == null || shardBy.trim().length() == 0) { debug("Shard {}: EXPLICIT_ID routing specified but no shard id property found for node {}", shardInstance, node.getNodeRef()); return negativeReturnValue(); } try { int shardid = Integer.parseInt(shardBy.trim()); return shardid == shardInstance; } catch (NumberFormatException exception) { debug("Shard {} EXPLICIT_ID routing specified but failed to parse a shard property value ({}) for node {}", shardInstance, shardBy, node.getNodeRef()); return negativeReturnValue(); } } ExplicitShardIdWithDynamicPropertyRouter();  ExplicitShardIdWithDynamicPropertyRouter(boolean isInStandaloneMode); @Override Boolean routeAcl(int shardCount, int shardInstance, Acl acl); @Override Boolean routeNode(int shardCount, int shardInstance, Node node); @Override Map<String, String> getProperties(Optional<QName> shardProperty);  }