diff --git a/buildSrc/src/main/groovy/nucleodb.app.gradle b/buildSrc/src/main/groovy/nucleodb.app.gradle index 202ef27..bf4fec3 100644 --- a/buildSrc/src/main/groovy/nucleodb.app.gradle +++ b/buildSrc/src/main/groovy/nucleodb.app.gradle @@ -3,7 +3,7 @@ plugins { } group = 'com.nucleodb' -version = '1.7.2' +version = '1.7.3' repositories { mavenCentral() diff --git a/buildSrc/src/main/groovy/nucleodb.library.gradle b/buildSrc/src/main/groovy/nucleodb.library.gradle index 1a01a7a..da5d48e 100644 --- a/buildSrc/src/main/groovy/nucleodb.library.gradle +++ b/buildSrc/src/main/groovy/nucleodb.library.gradle @@ -3,7 +3,7 @@ plugins { } group = 'com.nucleodb' -version = '1.9.2' +version = '1.9.3' repositories { mavenCentral() diff --git a/library/src/main/java/com/nucleocore/library/database/tables/ConnectionHandler.java b/library/src/main/java/com/nucleocore/library/database/tables/ConnectionHandler.java index bef0bde..df0ec9f 100644 --- a/library/src/main/java/com/nucleocore/library/database/tables/ConnectionHandler.java +++ b/library/src/main/java/com/nucleocore/library/database/tables/ConnectionHandler.java @@ -48,6 +48,7 @@ public class ConnectionHandler implements Serializable{ private Map partitionOffsets = new TreeMap<>(); private Set allConnections = new TreeSetExt<>(); + private transient NucleoDB nucleoDB; private ConnectionConfig config; @@ -157,9 +158,9 @@ public Stream getStream(DataEntry de){ } public Set getByLabel(DataEntry de, String label){ - Set tmp = connections.get(de.getKey()); + Set tmp = connections.get(de.getKey()+label); if(tmp!=null) { - return tmp.stream().filter(c->c.getLabel().equals(label)).map(c->c.clone()).collect(Collectors.toSet()); + return tmp.stream().map(c->c.clone()).collect(Collectors.toSet()); } return null; } @@ -170,14 +171,36 @@ public Stream getByLabelStream(DataEntry de, String label){ } return null; } - private void addConnection(Connection connection){ - connection.connectionHandler = this; - connectionByUUID.put(connection.getUuid(), connection); - String key = connection.getFromKey(); + + public Set getByLabelTo(DataEntry de, String label, DataEntry toDe){ + Set tmp = connections.get(de.getKey()+toDe.getKey()+label); + if(tmp!=null) { + return tmp.stream().map(c->c.clone()).collect(Collectors.toSet()); + } + return null; + } + public Stream getByLabelToStream(DataEntry de, String label,DataEntry toDe){ + Set tmp = getByLabelTo(de, label, toDe); + if(tmp!=null){ + return tmp.stream(); + } + return null; + } + + private void putConnectionInKey(String key, Connection connection){ if(!connections.containsKey(key)){ connections.put(key, new TreeSetExt<>()); } connections.get(key).add(connection); + } + + private void addConnection(Connection connection){ + connection.connectionHandler = this; + connectionByUUID.put(connection.getUuid(), connection); + String connectionKey = connection.getFromKey(); + this.putConnectionInKey(connectionKey, connection); + this.putConnectionInKey(connection.getFromKey()+connection.getLabel(), connection); + this.putConnectionInKey(connection.getFromKey()+connection.getToKey()+connection.getLabel(), connection); allConnections.add(connection); } private void removeConnection(Connection connection){ @@ -293,9 +316,7 @@ private boolean saveInternalConsumerSync(Connection connection) throws Interrupt } String changeUUID = UUID.randomUUID().toString(); CountDownLatch countDownLatch = new CountDownLatch(1); - consumers.put(changeUUID, (conn) -> { - countDownLatch.countDown(); - }); + consumers.put(changeUUID, (conn) -> countDownLatch.countDown()); if (saveInternalSync(connection, changeUUID)) { countDownLatch.await(); return true;