Skip to content

Commit

Permalink
cleanup logs
Browse files Browse the repository at this point in the history
  • Loading branch information
firestar committed Oct 25, 2023
1 parent bf3e67c commit 5df12d4
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 63 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/nucleodb.app.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = 'com.nucleodb'
version = '1.7.0'
version = '1.7.1'

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/nucleodb.library.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = 'com.nucleodb'
version = '1.9.0'
version = '1.9.1'

repositories {
mavenCentral()
Expand Down
10 changes: 5 additions & 5 deletions library/src/main/java/com/nucleocore/library/NucleoDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Set<DataEntry> getRelated(DataEntry dataEntry, Class clazz) {
if (relationship.clazz() == clazz) {
getRelatedByRelationship(dataEntry, set, localTableName, relationship);
} else {
Serializer.log("Relation ignored");
//Serializer.log("Relation ignored");
}
}
}
Expand All @@ -107,7 +107,7 @@ public Set<DataEntry> getRelatedRemote(DataEntry dataEntry, Class clazz, String
if (relationship.clazz() == clazz && index.equals(relationship.remoteKey())) {
getRelatedByRelationship(dataEntry, set, localTableName, relationship);
} else {
Serializer.log("Relation ignored");
//Serializer.log("Relation ignored");
}
}
}
Expand All @@ -123,7 +123,7 @@ public Set<DataEntry> getRelatedLocal(DataEntry dataEntry, Class clazz, String i
if (relationship.clazz() == clazz && index.equals(relationship.localKey())) {
getRelatedByRelationship(dataEntry, set, localTableName, relationship);
} else {
Serializer.log("Relation ignored");
//Serializer.log("Relation ignored");
}
}
}
Expand All @@ -134,9 +134,9 @@ private void getRelatedByRelationship(DataEntry dataEntry, Set<DataEntry> set, S
if (relationship.clazz().isAnnotationPresent(Table.class)) {
Table remoteTable = (Table) relationship.clazz().getAnnotation(Table.class);
String remoteTableName = remoteTable.value();
Serializer.log("getting for relationship from " + localTableName + " to " + remoteTableName);
//Serializer.log("getting for relationship from " + localTableName + " to " + remoteTableName);
try {
Serializer.log(relationship.localKey());
//Serializer.log(relationship.localKey());
List<Object> values = new TreeIndex().getValues(Queues.newLinkedBlockingDeque(Arrays.asList(relationship.localKey().split("\\."))), dataEntry.getData());
if (values.size() > 0) {
for (Object value : values) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.nucleocore.library.database.modifications;

public class Modify{
import java.io.Serializable;

public class Modify implements Serializable {
}
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ public void run() {
ModificationQueueItem mqi;
while (true) {
while (!modqueue.isEmpty()) {
System.out.println("SOMETHING FOUND");
Serializer.log(modqueue);
//System.out.println("SOMETHING FOUND");
//Serializer.log(modqueue);
mqi = modqueue.pop();
if (mqi != null) {
modify(mqi.getMod(), mqi.getModification());
Expand All @@ -471,12 +471,12 @@ public void modify(Modification mod, Object modification) {
//System.out.println("Create statement called");
if (c != null) {
if (this.config.getReadToTime() != null && c.getTime().isAfter(this.config.getReadToTime())) {
System.out.println("Create after target db date");
//System.out.println("Create after target db date");
return;
}
try {
if (connectionByUUID.containsKey(c.getConnection().getUuid())) {
System.out.println("Ignore already saved change.");
//System.out.println("Ignore already saved change.");
return; // ignore this create
}

Expand All @@ -496,17 +496,17 @@ public void modify(Modification mod, Object modification) {
//System.out.println("Delete statement called");
if (d != null) {
if (this.config.getReadToTime() != null && d.getTime().isAfter(this.config.getReadToTime())) {
System.out.println("Delete after target db date");
//System.out.println("Delete after target db date");
return;
}
Connection conn = connectionByUUID.get(d.getUuid());
if (conn != null) {
if (conn.getVersion() >= d.getVersion()) {
System.out.println("Ignore already saved change.");
//System.out.println("Ignore already saved change.");
return; // ignore change
}
if (conn.getVersion() + 1 != d.getVersion()) {
Serializer.log("Version not ready!");
//Serializer.log("Version not ready!");
modqueue.add(new ModificationQueueItem(mod, modification));
} else {
this.removeConnection(conn);
Expand All @@ -523,21 +523,21 @@ public void modify(Modification mod, Object modification) {
case CONNECTIONUPDATE:
ConnectionUpdate u = (ConnectionUpdate) modification;

System.out.println("Update statement called");
//System.out.println("Update statement called");
if (u != null) {
if (this.config.getReadToTime() != null && u.getTime().isAfter(this.config.getReadToTime())) {
System.out.println("Update after target db date");
//System.out.println("Update after target db date");
return;
}
try {
Connection conn = connectionByUUID.get(u.getUuid());
if (conn != null) {
if (conn.getVersion() >= u.getVersion()) {
System.out.println("Ignore already saved change.");
//System.out.println("Ignore already saved change.");
return; // ignore change
}
if (conn.getVersion() + 1 != u.getVersion()) {
Serializer.log("Version not ready!");
//Serializer.log("Version not ready!");
modqueue.add(new ModificationQueueItem(mod, modification));
} else {
Connection connectionTmp = Serializer.getObjectMapper().getOm().readValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ public void consume() {
if (this.config.getBootstrap() != null) {
String consumer = UUID.randomUUID().toString();
for (String kafkaBroker : this.config.getBootstrap().split(",")) {
System.out.println(this.config.getTable() + " with " + consumer + " connecting to: " + kafkaBroker);
//System.out.println(this.config.getTable() + " with " + consumer + " connecting to: " + kafkaBroker);
new ConsumerHandler(kafkaBroker, consumer, this, this.config.getTable());
}
}
}

public void exportTo(DataTable tb) {
for (DataEntry de : this.entries) {
Serializer.log("INSERTING " + de.getKey());
//Serializer.log("INSERTING " + de.getKey());
try {
tb.insertDataEntrySync(de);
} catch (InterruptedException e) {
Expand Down Expand Up @@ -510,7 +510,7 @@ public void run() {
ModificationQueueItem mqi;
while (true) {
while (!modqueue.isEmpty()) {
Serializer.log(modqueue);
//Serializer.log(modqueue);
mqi = modqueue.pop();
if (mqi != null) {
modify(mqi.getMod(), mqi.getModification());
Expand All @@ -537,12 +537,12 @@ public void modify(Modification mod, Object modification) {
//System.out.println("Create statement called");
if (c != null) {
if (this.config.getReadToTime() != null && c.getTime().isAfter(this.config.getReadToTime())) {
System.out.println("Create after target db date");
//System.out.println("Create after target db date");
return;
}
try {
if (keyToEntry.containsKey(c.getKey())) {
System.out.println("Ignore already saved change.");
//System.out.println("Ignore already saved change.");
return; // ignore this create
}
DataEntry dataEntry = new DataEntry(c);
Expand Down Expand Up @@ -582,17 +582,17 @@ public void modify(Modification mod, Object modification) {
//System.out.println("Delete statement called");
if (d != null) {
if (this.config.getReadToTime() != null && d.getTime().isAfter(this.config.getReadToTime())) {
System.out.println("Delete after target db date");
//System.out.println("Delete after target db date");
return;
}
DataEntry de = keyToEntry.get(d.getKey());
if (de != null) {
if (de.getVersion() >= d.getVersion()) {
System.out.println("Ignore already saved change.");
//System.out.println("Ignore already saved change.");
return; // ignore change
}
if (de.getVersion() + 1 != d.getVersion()) {
Serializer.log("Version not ready!");
//Serializer.log("Version not ready!");
modqueue.add(new ModificationQueueItem(mod, modification));
} else {
entries.remove(de);
Expand All @@ -614,21 +614,21 @@ public void modify(Modification mod, Object modification) {
case UPDATE:
Update u = (Update) modification;

System.out.println("Update statement called");
//System.out.println("Update statement called");
if (u != null) {
if (this.config.getReadToTime() != null && u.getTime().isAfter(this.config.getReadToTime())) {
System.out.println("Update after target db date");
//System.out.println("Update after target db date");
return;
}
try {
DataEntry de = keyToEntry.get(u.getKey());
if (de != null) {
if (de.getVersion() >= u.getVersion()) {
System.out.println("Ignore already saved change.");
//System.out.println("Ignore already saved change.");
return; // ignore change
}
if (de.getVersion() + 1 != u.getVersion()) {
Serializer.log("Version not ready!");
//Serializer.log("Version not ready!");
modqueue.add(new ModificationQueueItem(mod, modification));
} else {
de.setReference(u.getChangesPatch().apply(de.getReference()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public TreeIndex(String indexedKey) {
@Override
public void add(DataEntry dataEntry) throws JsonProcessingException {
List<Object> values = getIndexValue(dataEntry);
System.out.println(Serializer.getObjectMapper().getOm().writeValueAsString(values));
//System.out.println(Serializer.getObjectMapper().getOm().writeValueAsString(values));
values.forEach(val->{
Set<DataEntry> entries;
synchronized (index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ public static Function createComparatorFunction(String column){
// handle cache
Map<String, Object> objCache = cache.get(s);
if(objCache!=null && objCache.containsKey(column)){
Serializer.log("Use cache for "+column +" for "+s.toString());
//Serializer.log("Use cache for "+column +" for "+s.toString());
return objCache.get(column);
}
Serializer.log("Grab data from "+column +" for "+s.toString());
//Serializer.log("Grab data from "+column +" for "+s.toString());
Queue<String> queue = Queues.newLinkedBlockingDeque(Arrays.asList(column.split("\\.")));
//Serializer.log(queue);
Object o = s;
Expand Down Expand Up @@ -325,13 +325,13 @@ public static Set<DataEntry> evaluateWhere(Expression expr, DataTable table) {
// System.out.println(left + " != " + right);
return table.getNotEqual(left, right);
} else {
System.out.println(binary.getClass().getName());
System.out.println(binary.getLeftExpression().getClass().getName());
System.out.println(binary.getRightExpression().getClass().getName());
//System.out.println(binary.getClass().getName());
//System.out.println(binary.getLeftExpression().getClass().getName());
//System.out.println(binary.getRightExpression().getClass().getName());
}
// Other binary expressions can be added similarly
} else {
System.out.println(expr.getClass().getName());
//System.out.println(expr.getClass().getName());
}
// Other conditions (like OrExpression) can be added similarly
return new TreeSet<>();
Expand All @@ -340,7 +340,7 @@ public static Set<DataEntry> evaluateWhere(Expression expr, DataTable table) {
public static DataEntry handleInsert(Insert sqlStatement, NucleoDB nucleoDB) {
String tableName = sqlStatement.getTable().getName();
try {
Serializer.log("looking at table: "+tableName);
//Serializer.log("looking at table: "+tableName);
DataTable table = nucleoDB.getTable(tableName);
Object obj = table.getConfig().getClazz().getConstructor().newInstance();

Expand Down Expand Up @@ -372,7 +372,7 @@ public static void setColumnVal(Expression expression, String column, Object obj
if (obj instanceof Collection) {
((Collection) obj).add(((StringValue) expression).getValue());
} else {
System.out.println("lost string");
//System.out.println("lost string");
}
} else {

Expand All @@ -390,13 +390,13 @@ public static void setColumnVal(Expression expression, String column, Object obj
} else if (listValueType == Integer.class) {
((Collection) obj).add(((LongValue) expression).getValue());
} else {
Serializer.log("In LongValue " + listValueType.getName());
//Serializer.log("In LongValue " + listValueType.getName());
}
} else {
((Collection) obj).add(((LongValue) expression).getValue());
}
} else {
System.out.println("lost long");
//System.out.println("lost long");
}
} else {
PropertyDescriptor propertyDescriptor = new PropertyDescriptor(column, obj.getClass());
Expand All @@ -417,13 +417,13 @@ public static void setColumnVal(Expression expression, String column, Object obj
} else if (listValueType == Double.class) {
((Collection) obj).add(((DoubleValue) expression).getValue());
} else {
Serializer.log("In DoubleValue " + listValueType.getName());
//Serializer.log("In DoubleValue " + listValueType.getName());
}
} else {
((Collection) obj).add(((DoubleValue) expression).getValue());
}
} else {
System.out.println("lost long");
//System.out.println("lost long");
}
} else {
PropertyDescriptor propertyDescriptor = new PropertyDescriptor(column, obj.getClass());
Expand Down Expand Up @@ -518,7 +518,7 @@ public static void setColumnVal(Expression expression, String column, Object obj
} else if (expression instanceof Parenthesis) {
setColumnVal(((Parenthesis) expression).getExpression(), column, obj, field);
} else {
System.out.println("last: " + expression.getClass().getName());
//System.out.println("last: " + expression.getClass().getName());
}
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -550,7 +550,7 @@ public static boolean handleUpdate(Update sqlStatement, NucleoDB nucleoDB) {
});
countDownLatch.await();
}
Serializer.log("Saved changed "+dataEntriesList.get().size());
//Serializer.log("Saved changed "+dataEntriesList.get().size());
} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -680,16 +680,16 @@ public static boolean handleDelete(Delete sqlStatement, NucleoDB nucleoDB) {

dataEntries = dataEntries.subList((offset>dataEntries.size())?dataEntries.size():offset, (offset+count>dataEntries.size())?dataEntries.size():offset+count);

Serializer.log("TO DELETE");
Serializer.log(dataEntries);
//Serializer.log("TO DELETE");
//Serializer.log(dataEntries);
if(dataEntries.size()!=0) {
CountDownLatch countDownLatch = new CountDownLatch(dataEntries.size());
dataEntries.forEach(x -> {
new Thread(() -> {
if (table.getDataEntries().contains(x)) {
table.delete(x, (d) -> {
Serializer.log("DELETED ");
Serializer.log(d);
//Serializer.log("DELETED ");
//Serializer.log(d);
countDownLatch.countDown();
});
} else {
Expand All @@ -700,7 +700,7 @@ public static boolean handleDelete(Delete sqlStatement, NucleoDB nucleoDB) {
countDownLatch.await();
}

Serializer.log("Deleted changed "+dataEntries.size());
//Serializer.log("Deleted changed "+dataEntries.size());
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ConsumerHandler(String bootstrap, String groupName, DataTable database, S
this.consumer = createConsumer(bootstrap, groupName);

this.subscribe(new String[]{table});
Serializer.log(table);
//Serializer.log(table);

consumer.commitSync();

Expand Down Expand Up @@ -76,7 +76,7 @@ public ConsumerHandler(String bootstrap, String groupName, ConnectionHandler con
this.consumer = createConsumer(bootstrap, groupName);

this.subscribe(new String[]{table});
Serializer.log(table);
//Serializer.log(table);

consumer.commitSync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void callback(ArgumentAction argumentAction, Object obj) {
} else if (isDebug() && obj instanceof ArgumentKafkaMessage) {
argumentMessageQueue.add((ArgumentKafkaMessage) obj);
}else{
System.out.println(obj.getClass().getName());
//System.out.println(obj.getClass().getName());
}
break;
case RUN_FINAL_ACTION:
Expand Down
Loading

0 comments on commit 5df12d4

Please sign in to comment.