private OSocketFactory(final OContextConfiguration iConfig) { config = iConfig; useSSL = iConfig.getValueAsBoolean(OGlobalConfiguration.CLIENT_USE_SSL); keyStorePath = (String) iConfig.getValue(OGlobalConfiguration.CLIENT_SSL_KEYSTORE); keyStorePassword = (String) iConfig.getValue(OGlobalConfiguration.CLIENT_SSL_KEYSTORE_PASSWORD); trustStorePath = (String) iConfig.getValue(OGlobalConfiguration.CLIENT_SSL_TRUSTSTORE); trustStorePassword = (String) iConfig.getValue(OGlobalConfiguration.CLIENT_SSL_TRUSTSTORE_PASSWORD); }
public String getValueAsString(final String iName, final String iDefaultValue) { return getValue(iName, iDefaultValue); }
public int getMinimumClusters() { lock.acquireReadLock(); try { final int mc = getContextConfiguration().getValueAsInteger(OGlobalConfiguration.CLASS_MINIMUM_CLUSTERS); if (mc == 0) { autoInitClusters(); return (Integer) getContextConfiguration().getValue(OGlobalConfiguration.CLASS_MINIMUM_CLUSTERS); } return mc; } finally { lock.releaseReadLock(); } }
public String getValueAsString(final OGlobalConfiguration iConfig) { final Object v = getValue(iConfig); if (v == null) return null; return v.toString(); }
private OSocketFactory(OContextConfiguration iConfig) { config = iConfig; useSSL = iConfig.getValueAsBoolean(OGlobalConfiguration.CLIENT_USE_SSL); keyStorePath = (String) iConfig .getValue(OGlobalConfiguration.CLIENT_SSL_KEYSTORE); keyStorePassword = (String) iConfig .getValue(OGlobalConfiguration.CLIENT_SSL_KEYSTORE_PASSWORD); trustStorePath = (String) iConfig .getValue(OGlobalConfiguration.CLIENT_SSL_TRUSTSTORE); trustStorePassword = (String) iConfig .getValue(OGlobalConfiguration.CLIENT_SSL_TRUSTSTORE_PASSWORD); }
public boolean getValueAsBoolean(final OGlobalConfiguration iConfig) { final Object v = getValue(iConfig); if (v == null) return false; return v instanceof Boolean ? ((Boolean) v).booleanValue() : Boolean.parseBoolean(v.toString()); }
public int getValueAsInteger(final OGlobalConfiguration iConfig) { final Object v = getValue(iConfig); if (v == null) return 0; return v instanceof Integer ? ((Integer) v).intValue() : Integer.parseInt(v.toString()); }
public float getValueAsFloat(final OGlobalConfiguration iConfig) { final Object v = getValue(iConfig); if (v == null) return 0; return v instanceof Float ? ((Float) v).floatValue() : Float.parseFloat(v.toString()); }
public long getValueAsLong(final OGlobalConfiguration iConfig) { final Object v = getValue(iConfig); if (v == null) return 0; return v instanceof Long ? ((Long) v).intValue() : Long.parseLong(v.toString()); }
public static void addOp(ODocument iDocument, byte iType, ODatabaseDocument database) { if (Boolean.FALSE.equals(database.getConfiguration().getValue(QUERY_LIVE_SUPPORT))) return; ODatabaseDocument db = database; OLiveQueryOps ops = getOpsReference((ODatabaseInternal) db); if (!ops.queueThread.hasListeners()) return; ORecordOperation result = new ORecordOperation(iDocument, iType); synchronized (ops.pendingOps) { List<ORecordOperation> list = ops.pendingOps.get(db); if (list == null) { list = new ArrayList<ORecordOperation>(); ops.pendingOps.put(db, list); } list.add(result); } }
public static void notifyForTxChanges(ODatabaseDocument database) { if (Boolean.FALSE.equals(database.getConfiguration().getValue(QUERY_LIVE_SUPPORT))) return; OLiveQueryOps ops = getOpsReference((ODatabaseInternal) database); List<OLiveQueryOp> list; synchronized (ops.pendingOps) { list = ops.pendingOps.remove(database); } // TODO sync if (list != null) { for (OLiveQueryOp item : list) { item.originalDoc = item.originalDoc.copy(); ops.enqueue(item); } } }
public static void removePendingDatabaseOps(ODatabaseDocument database) { try { if (database.isClosed() || Boolean.FALSE.equals(database.getConfiguration().getValue(QUERY_LIVE_SUPPORT))) return; OLiveQueryOps ops = getOpsReference((ODatabaseInternal) database); synchronized (ops.pendingOps) { ops.pendingOps.remove(database); } } catch (ODatabaseException ex) { //This catch and log the exception because in some case is suppressing the real exception OLogManager.instance().error(database, "Error cleaning the live query resources", ex); } }
public static void removePendingDatabaseOps(ODatabase iDatabase) { try { if (iDatabase.isClosed() || Boolean.FALSE.equals(iDatabase.getConfiguration().getValue(QUERY_LIVE_SUPPORT))) return; OLiveQueryOps ops = getOpsReference((ODatabaseInternal) iDatabase); synchronized (ops.pendingOps) { ops.pendingOps.remove(iDatabase); } } catch (ODatabaseException ex) { //This catch and log the exception because in some case is suppressing the real exception OLogManager.instance().error(iDatabase, "Error cleaning the live query resources", ex); } }
public static void addOp(ODocument iDocument, byte iType, ODatabaseDocument database) { if (Boolean.FALSE.equals(database.getConfiguration().getValue(QUERY_LIVE_SUPPORT))) return; ODatabaseDocument db = database; OLiveQueryOps ops = getOpsReference((ODatabaseInternal) db); if (!ops.hasListeners()) return; OResult before = iType == ORecordOperation.CREATED ? null : calculateBefore(iDocument); OResult after = iType == ORecordOperation.DELETED ? null : calculateAfter(iDocument); OLiveQueryOp result = new OLiveQueryOp(iDocument, before, after, iType); synchronized (ops.pendingOps) { List<OLiveQueryOp> list = ops.pendingOps.get(db); if (list == null) { list = new ArrayList<>(); ops.pendingOps.put(db, list); } if (result.type == ORecordOperation.UPDATED) { OLiveQueryOp prev = prevousUpdate(list, result.originalDoc); if (prev == null) { list.add(result); } else { prev.after = result.after; } } else { list.add(result); } } }
public static void notifyForTxChanges(ODatabase iDatabase) { if (Boolean.FALSE.equals(iDatabase.getConfiguration().getValue(QUERY_LIVE_SUPPORT))) return; OLiveQueryOps ops = getOpsReference((ODatabaseInternal) iDatabase); List<ORecordOperation> list; synchronized (ops.pendingOps) { list = ops.pendingOps.remove(iDatabase); } // TODO sync if (list != null) { for (ORecordOperation item : list) { item.setRecord(item.getRecord().copy()); ops.queueThread.enqueue(item); } } }
public static void unsubscribe(Integer id, ODatabaseInternal db) { if (Boolean.FALSE.equals(db.getConfiguration().getValue(QUERY_LIVE_SUPPORT))) { OLogManager.instance().warn(db, "Live query support is disabled impossible to unsubscribe a listener, set '%s' to true for enable the live query support", QUERY_LIVE_SUPPORT.getKey()); return; } try { OLiveQueryOps ops = getOpsReference(db); synchronized (ops.threadLock) { ops.unsubscribe(id); } } catch (Exception e) { OLogManager.instance().warn(OLiveQueryHookV2.class, "Error on unsubscribing client", e); } }
public static void unsubscribe(Integer id, ODatabaseInternal db) { if (Boolean.FALSE.equals(db.getConfiguration().getValue(QUERY_LIVE_SUPPORT))) { OLogManager.instance().warn(db, "Live query support is disabled impossible to unsubscribe a listener, set '%s' to true for enable the live query support", QUERY_LIVE_SUPPORT.getKey()); return; } try { OLiveQueryOps ops = getOpsReference(db); synchronized (ops.threadLock) { ops.queueThread.unsubscribe(id); } } catch (Exception e) { OLogManager.instance().warn(OLiveQueryHook.class, "Error on unsubscribing client", e); } }
public static Integer subscribe(Integer token, OLiveQueryListenerV2 iListener, ODatabaseInternal db) { if (Boolean.FALSE.equals(db.getConfiguration().getValue(QUERY_LIVE_SUPPORT))) { OLogManager.instance().warn(db, "Live query support is disabled impossible to subscribe a listener, set '%s' to true for enable the live query support", QUERY_LIVE_SUPPORT.getKey()); return -1; } OLiveQueryOps ops = getOpsReference(db); synchronized (ops.threadLock) { if (!ops.queueThread.isAlive()) { ops.queueThread = ops.queueThread.clone(); ops.queueThread.start(); } } return ops.subscribe(token, iListener); }
public static Integer subscribe(Integer token, OLiveQueryListener iListener, ODatabaseInternal db) { if (Boolean.FALSE.equals(db.getConfiguration().getValue(QUERY_LIVE_SUPPORT))) { OLogManager.instance().warn(db, "Live query support is disabled impossible to subscribe a listener, set '%s' to true for enable the live query support", QUERY_LIVE_SUPPORT.getKey()); return -1; } OLiveQueryOps ops = getOpsReference(db); synchronized (ops.threadLock) { if (!ops.queueThread.isAlive()) { ops.queueThread = ops.queueThread.clone(); ops.queueThread.start(); } } return ops.queueThread.subscribe(token, iListener); }