@Test public void testDBIDRANGEWithShardRangeKey() { Properties mockProperties = mock(Properties.class); when(mockProperties.containsKey(SHARD_RANGE_KEY)).thenReturn(true); when(mockProperties.getProperty(SHARD_RANGE_KEY)).thenReturn("100000000-150000000"); DocRouter docRouter = DocRouterFactory.getRouter(mockProperties, ShardMethodEnum.DB_ID_RANGE); assertTrue("Expected to get a DBIDRangeRouter.", docRouter instanceof DBIDRangeRouter); DBIDRangeRouter dbidRangeRouter = (DBIDRangeRouter) docRouter; assertEquals("Unexpected start of range.", dbidRangeRouter.getStartRange(), 100000000L); assertEquals("Unexpected end of range.", dbidRangeRouter.getEndRange(), 150000000L); }
public static DocRouter getRouter(Properties properties, ShardMethodEnum method) { switch(method) { case DB_ID: LOGGER.info("Sharding via DB_ID"); return new DBIDRouter(); case DB_ID_RANGE: if(!properties.containsKey(SHARD_RANGE_KEY)) { throw new AlfrescoRuntimeException("DB_ID_RANGE sharding requires the " + SHARD_RANGE_KEY + " property to be set."); } LOGGER.info("Sharding via DB_ID_RANGE"); String[] pair = properties.getProperty(SHARD_RANGE_KEY).split("-"); long start = Long.parseLong(pair[0]); long end = Long.parseLong(pair[1]); return new DBIDRangeRouter(start, end); case ACL_ID: LOGGER.info("Sharding via ACL_ID"); return new ACLIDMurmurRouter(); case MOD_ACL_ID: LOGGER.info("Sharding via MOD_ACL_ID"); return new ACLIDModRouter(); case DATE: LOGGER.info("Sharding via DATE"); return new DateMonthRouter(properties.getProperty(SHARD_DATE_GROUPING_KEY, "1")); case PROPERTY: LOGGER.info("Sharding via PROPERTY"); return new PropertyRouter(properties.getProperty(SHARD_REGEX_KEY, "")); case LAST_REGISTERED_INDEXING_SHARD: LOGGER.warn("Sharding via LAST_REGISTERED_INDEXING_SHARD: Note this is available at the moment as an Early Access/preview feature!"); return new ExplicitShardIdWithStaticPropertyRouter(); case EXPLICIT_ID_FALLBACK_LRIS: LOGGER.warn("Sharding via EXPLICIT_ID_FALLBACK_LRIS: Note the LRIS Router (which is part of this composite router) is available at the moment as an Early Access/preview feature!"); return new DocRouterWithFallback( new ExplicitShardIdWithDynamicPropertyRouter(false), new ExplicitShardIdWithStaticPropertyRouter()); case EXPLICIT_ID: LOGGER.info("Sharding via EXPLICIT_ID"); return new DocRouterWithFallback( new ExplicitShardIdWithDynamicPropertyRouter(false), new DBIDRouter()); default: LOGGER.warn("WARNING! Unknown/unsupported sharding method ({}). System will fallback to DB_ID", method); return new DBIDRouter(); } }
DocRouterFactory { public static DocRouter getRouter(Properties properties, ShardMethodEnum method) { switch(method) { case DB_ID: LOGGER.info("Sharding via DB_ID"); return new DBIDRouter(); case DB_ID_RANGE: if(!properties.containsKey(SHARD_RANGE_KEY)) { throw new AlfrescoRuntimeException("DB_ID_RANGE sharding requires the " + SHARD_RANGE_KEY + " property to be set."); } LOGGER.info("Sharding via DB_ID_RANGE"); String[] pair = properties.getProperty(SHARD_RANGE_KEY).split("-"); long start = Long.parseLong(pair[0]); long end = Long.parseLong(pair[1]); return new DBIDRangeRouter(start, end); case ACL_ID: LOGGER.info("Sharding via ACL_ID"); return new ACLIDMurmurRouter(); case MOD_ACL_ID: LOGGER.info("Sharding via MOD_ACL_ID"); return new ACLIDModRouter(); case DATE: LOGGER.info("Sharding via DATE"); return new DateMonthRouter(properties.getProperty(SHARD_DATE_GROUPING_KEY, "1")); case PROPERTY: LOGGER.info("Sharding via PROPERTY"); return new PropertyRouter(properties.getProperty(SHARD_REGEX_KEY, "")); case LAST_REGISTERED_INDEXING_SHARD: LOGGER.warn("Sharding via LAST_REGISTERED_INDEXING_SHARD: Note this is available at the moment as an Early Access/preview feature!"); return new ExplicitShardIdWithStaticPropertyRouter(); case EXPLICIT_ID_FALLBACK_LRIS: LOGGER.warn("Sharding via EXPLICIT_ID_FALLBACK_LRIS: Note the LRIS Router (which is part of this composite router) is available at the moment as an Early Access/preview feature!"); return new DocRouterWithFallback( new ExplicitShardIdWithDynamicPropertyRouter(false), new ExplicitShardIdWithStaticPropertyRouter()); case EXPLICIT_ID: LOGGER.info("Sharding via EXPLICIT_ID"); return new DocRouterWithFallback( new ExplicitShardIdWithDynamicPropertyRouter(false), new DBIDRouter()); default: LOGGER.warn("WARNING! Unknown/unsupported sharding method ({}). System will fallback to DB_ID", method); return new DBIDRouter(); } } }
DocRouterFactory { public static DocRouter getRouter(Properties properties, ShardMethodEnum method) { switch(method) { case DB_ID: LOGGER.info("Sharding via DB_ID"); return new DBIDRouter(); case DB_ID_RANGE: if(!properties.containsKey(SHARD_RANGE_KEY)) { throw new AlfrescoRuntimeException("DB_ID_RANGE sharding requires the " + SHARD_RANGE_KEY + " property to be set."); } LOGGER.info("Sharding via DB_ID_RANGE"); String[] pair = properties.getProperty(SHARD_RANGE_KEY).split("-"); long start = Long.parseLong(pair[0]); long end = Long.parseLong(pair[1]); return new DBIDRangeRouter(start, end); case ACL_ID: LOGGER.info("Sharding via ACL_ID"); return new ACLIDMurmurRouter(); case MOD_ACL_ID: LOGGER.info("Sharding via MOD_ACL_ID"); return new ACLIDModRouter(); case DATE: LOGGER.info("Sharding via DATE"); return new DateMonthRouter(properties.getProperty(SHARD_DATE_GROUPING_KEY, "1")); case PROPERTY: LOGGER.info("Sharding via PROPERTY"); return new PropertyRouter(properties.getProperty(SHARD_REGEX_KEY, "")); case LAST_REGISTERED_INDEXING_SHARD: LOGGER.warn("Sharding via LAST_REGISTERED_INDEXING_SHARD: Note this is available at the moment as an Early Access/preview feature!"); return new ExplicitShardIdWithStaticPropertyRouter(); case EXPLICIT_ID_FALLBACK_LRIS: LOGGER.warn("Sharding via EXPLICIT_ID_FALLBACK_LRIS: Note the LRIS Router (which is part of this composite router) is available at the moment as an Early Access/preview feature!"); return new DocRouterWithFallback( new ExplicitShardIdWithDynamicPropertyRouter(false), new ExplicitShardIdWithStaticPropertyRouter()); case EXPLICIT_ID: LOGGER.info("Sharding via EXPLICIT_ID"); return new DocRouterWithFallback( new ExplicitShardIdWithDynamicPropertyRouter(false), new DBIDRouter()); default: LOGGER.warn("WARNING! Unknown/unsupported sharding method ({}). System will fallback to DB_ID", method); return new DBIDRouter(); } }  }
DocRouterFactory { public static DocRouter getRouter(Properties properties, ShardMethodEnum method) { switch(method) { case DB_ID: LOGGER.info("Sharding via DB_ID"); return new DBIDRouter(); case DB_ID_RANGE: if(!properties.containsKey(SHARD_RANGE_KEY)) { throw new AlfrescoRuntimeException("DB_ID_RANGE sharding requires the " + SHARD_RANGE_KEY + " property to be set."); } LOGGER.info("Sharding via DB_ID_RANGE"); String[] pair = properties.getProperty(SHARD_RANGE_KEY).split("-"); long start = Long.parseLong(pair[0]); long end = Long.parseLong(pair[1]); return new DBIDRangeRouter(start, end); case ACL_ID: LOGGER.info("Sharding via ACL_ID"); return new ACLIDMurmurRouter(); case MOD_ACL_ID: LOGGER.info("Sharding via MOD_ACL_ID"); return new ACLIDModRouter(); case DATE: LOGGER.info("Sharding via DATE"); return new DateMonthRouter(properties.getProperty(SHARD_DATE_GROUPING_KEY, "1")); case PROPERTY: LOGGER.info("Sharding via PROPERTY"); return new PropertyRouter(properties.getProperty(SHARD_REGEX_KEY, "")); case LAST_REGISTERED_INDEXING_SHARD: LOGGER.warn("Sharding via LAST_REGISTERED_INDEXING_SHARD: Note this is available at the moment as an Early Access/preview feature!"); return new ExplicitShardIdWithStaticPropertyRouter(); case EXPLICIT_ID_FALLBACK_LRIS: LOGGER.warn("Sharding via EXPLICIT_ID_FALLBACK_LRIS: Note the LRIS Router (which is part of this composite router) is available at the moment as an Early Access/preview feature!"); return new DocRouterWithFallback( new ExplicitShardIdWithDynamicPropertyRouter(false), new ExplicitShardIdWithStaticPropertyRouter()); case EXPLICIT_ID: LOGGER.info("Sharding via EXPLICIT_ID"); return new DocRouterWithFallback( new ExplicitShardIdWithDynamicPropertyRouter(false), new DBIDRouter()); default: LOGGER.warn("WARNING! Unknown/unsupported sharding method ({}). System will fallback to DB_ID", method); return new DBIDRouter(); } }  static DocRouter getRouter(Properties properties, ShardMethodEnum method); }
DocRouterFactory { public static DocRouter getRouter(Properties properties, ShardMethodEnum method) { switch(method) { case DB_ID: LOGGER.info("Sharding via DB_ID"); return new DBIDRouter(); case DB_ID_RANGE: if(!properties.containsKey(SHARD_RANGE_KEY)) { throw new AlfrescoRuntimeException("DB_ID_RANGE sharding requires the " + SHARD_RANGE_KEY + " property to be set."); } LOGGER.info("Sharding via DB_ID_RANGE"); String[] pair = properties.getProperty(SHARD_RANGE_KEY).split("-"); long start = Long.parseLong(pair[0]); long end = Long.parseLong(pair[1]); return new DBIDRangeRouter(start, end); case ACL_ID: LOGGER.info("Sharding via ACL_ID"); return new ACLIDMurmurRouter(); case MOD_ACL_ID: LOGGER.info("Sharding via MOD_ACL_ID"); return new ACLIDModRouter(); case DATE: LOGGER.info("Sharding via DATE"); return new DateMonthRouter(properties.getProperty(SHARD_DATE_GROUPING_KEY, "1")); case PROPERTY: LOGGER.info("Sharding via PROPERTY"); return new PropertyRouter(properties.getProperty(SHARD_REGEX_KEY, "")); case LAST_REGISTERED_INDEXING_SHARD: LOGGER.warn("Sharding via LAST_REGISTERED_INDEXING_SHARD: Note this is available at the moment as an Early Access/preview feature!"); return new ExplicitShardIdWithStaticPropertyRouter(); case EXPLICIT_ID_FALLBACK_LRIS: LOGGER.warn("Sharding via EXPLICIT_ID_FALLBACK_LRIS: Note the LRIS Router (which is part of this composite router) is available at the moment as an Early Access/preview feature!"); return new DocRouterWithFallback( new ExplicitShardIdWithDynamicPropertyRouter(false), new ExplicitShardIdWithStaticPropertyRouter()); case EXPLICIT_ID: LOGGER.info("Sharding via EXPLICIT_ID"); return new DocRouterWithFallback( new ExplicitShardIdWithDynamicPropertyRouter(false), new DBIDRouter()); default: LOGGER.warn("WARNING! Unknown/unsupported sharding method ({}). System will fallback to DB_ID", method); return new DBIDRouter(); } }  static DocRouter getRouter(Properties properties, ShardMethodEnum method); static final String SHARD_KEY_KEY; static final String SHARD_RANGE_KEY; static final String SHARD_DATE_GROUPING_KEY; static final String SHARD_REGEX_KEY; }