private void registerLastRevRecoveryJob(final DocumentNodeStore nodeStore) { long leaseTime = toLong(context.getProperties().get(PROP_REV_RECOVERY_INTERVAL), ClusterNodeInfo.DEFAULT_LEASE_UPDATE_INTERVAL_MILLIS); addRegistration(scheduleWithFixedDelay(whiteboard, new LastRevRecoveryJob(nodeStore), TimeUnit.MILLISECONDS.toSeconds(leaseTime), false/*runOnSingleClusterNode*/, true /*use dedicated pool*/)); }
@Override public Future addingService(ServiceReference<Runnable> reference) { Runnable runnable = context.getService(reference); long period = PropertiesUtil.toLong(reference.getProperty("scheduler.period"), -1); boolean concurrent = PropertiesUtil.toBoolean(reference.getProperty("scheduler.concurrent"), false); Future future = null; if (period != -1) { if (concurrent) { future = getExecutor().scheduleAtFixedRate( runnable, period, period, TimeUnit.SECONDS); } else { future = getExecutor().scheduleWithFixedDelay( runnable, period, period, TimeUnit.SECONDS); } } return future; }
private void registerLastRevRecoveryJob(final DocumentNodeStore nodeStore) { long leaseTime = toLong(context.getProperties().get(PROP_REV_RECOVERY_INTERVAL), ClusterNodeInfo.DEFAULT_LEASE_UPDATE_INTERVAL_MILLIS); addRegistration(scheduleWithFixedDelay(whiteboard, new LastRevRecoveryJob(nodeStore), TimeUnit.MILLISECONDS.toSeconds(leaseTime), false/*runOnSingleClusterNode*/, true /*use dedicated pool*/)); }
@Override protected DataStore createDataStore(ComponentContext context, Map<String, Object> config) { long cacheSize = PropertiesUtil.toLong(config.get(CACHE_SIZE), 0L); // return CachingFDS when cacheSize > 0 if (cacheSize > 0) { String fsBackendPath = PropertiesUtil.toString(config.get(PATH), null); Preconditions.checkNotNull(fsBackendPath, "Cannot create " + "FileDataStoreService with caching. [{path}] property not configured."); config.remove(PATH); config.remove(CACHE_SIZE); config.put(FS_BACKEND_PATH, fsBackendPath); config.put("cacheSize", cacheSize); String cachePath = PropertiesUtil.toString(config.get(CACHE_PATH), null); if (cachePath != null) { config.remove(CACHE_PATH); config.put(PATH, cachePath); } Properties properties = new Properties(); properties.putAll(config); log.info("Initializing with properties " + properties); return getCachingDataStore(properties, context); } else { log.info("OakFileDataStore initialized"); return new OakFileDataStore(); } }
@Override protected DataStore createDataStore(ComponentContext context, Map<String, Object> config) { long cacheSize = PropertiesUtil.toLong(config.get(CACHE_SIZE), 0L); // return CachingFDS when cacheSize > 0 if (cacheSize > 0) { String fsBackendPath = PropertiesUtil.toString(config.get(PATH), null); Preconditions.checkNotNull(fsBackendPath, "Cannot create " + "FileDataStoreService with caching. [{path}] property not configured."); config.remove(PATH); config.remove(CACHE_SIZE); config.put(FS_BACKEND_PATH, fsBackendPath); config.put("cacheSize", cacheSize); String cachePath = PropertiesUtil.toString(config.get(CACHE_PATH), null); if (cachePath != null) { config.remove(CACHE_PATH); config.put(PATH, cachePath); } Properties properties = new Properties(); properties.putAll(config); log.info("Initializing with properties " + properties); return getCachingDataStore(properties, context); } else { log.info("OakFileDataStore initialized"); return new OakFileDataStore(); } }
@Override protected DataStore createDataStore(ComponentContext context, Map<String, Object> config) { long cacheSize = PropertiesUtil.toLong(config.get(CACHE_SIZE), 0L); // return CachingFDS when cacheSize > 0 if (cacheSize > 0) { String fsBackendPath = PropertiesUtil.toString(config.get(PATH), null); Preconditions.checkNotNull(fsBackendPath, "Cannot create " + "FileDataStoreService with caching. [{path}] property not configured."); config.remove(PATH); config.remove(CACHE_SIZE); config.put(FS_BACKEND_PATH, fsBackendPath); config.put("cacheSize", cacheSize); String cachePath = PropertiesUtil.toString(config.get(CACHE_PATH), null); if (cachePath != null) { config.remove(CACHE_PATH); config.put(PATH, cachePath); } Properties properties = new Properties(); properties.putAll(config); log.info("Initializing with properties " + properties); return getCachingDataStore(properties, context); } else { log.info("OakFileDataStore initialized"); return new OakFileDataStore(); } }
} else if (type.isAssignableFrom(Long.TYPE) || type.isAssignableFrom(Long.class)) { setter.invoke(instance, toLong(value, 0)); } else if (type.isAssignableFrom(Double.TYPE) || type.isAssignableFrom(Double.class)) {
} else if (type.isAssignableFrom(Long.TYPE) || type.isAssignableFrom(Long.class)) { setter.invoke(instance, toLong(value, 0)); } else if (type.isAssignableFrom(Double.TYPE) || type.isAssignableFrom(Double.class)) {
} else if (type.isAssignableFrom(Long.TYPE) || type.isAssignableFrom(Long.class)) { setter.invoke(instance, toLong(value, 0)); } else if (type.isAssignableFrom(Double.TYPE) || type.isAssignableFrom(Double.class)) {
@SuppressWarnings("UnnecessaryBoxing") @Test public void testToLong() { assertEquals(2, PropertiesUtil.toLong(null, 2)); assertEquals(2, PropertiesUtil.toLong(1.0, 2)); assertEquals(2, PropertiesUtil.toLong(new Double(1.0), 2)); assertEquals(5, PropertiesUtil.toLong(new Long(5), 2)); assertEquals(5, PropertiesUtil.toLong(new Integer(5), 2)); assertEquals(2, PropertiesUtil.toLong("abc", 2)); }