Skip to content

Commit

Permalink
Ignore cyclic dependency situations
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufbulentavci committed Jun 30, 2022
1 parent 4315590 commit b89cc87
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>ozgur</groupId>
<artifactId>ozgurdbsync</artifactId>
<packaging>jar</packaging>
<version>1.3.0</version>
<version>1.3.1</version>
<name>pgdatasynctr</name>
<url>http://maven.apache.org</url>

Expand Down
69 changes: 40 additions & 29 deletions src/main/java/ozgurdbsync/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public class Main {

public static void main(String[] args) throws IOException, SQLException {
//
if (args.length != 1)
throw new RuntimeException("Usage: java -cp ./ozgurdbsynch.jar ozgurdbsync/Main path.ini.file");

Ini ini = new Ini(args[0]);
// Ini ini = new Ini("/home/ybavci/workspace/ozgurdbsync/src/test/resources/altin_test.ini");
// if (args.length != 1)
// throw new RuntimeException("Usage: java -cp ./ozgurdbsynch.jar ozgurdbsync/Main path.ini.file");
//
// Ini ini = new Ini(args[0]);
Ini ini = new Ini("/home/ybavci/workspace/ozgurdbsync/src/test/resources/altin_test.ini");

Map<String, TableProps> tableProps = new HashMap<String, TableProps>();

Expand Down Expand Up @@ -79,7 +79,8 @@ public static void main(String[] args) throws IOException, SQLException {
System.out.println("--BEGIN");
Set<String> processed = new HashSet<>();
boolean success = false;
for (int i = 0; i < 10000; i++) {
boolean ignoreDependency = false;
for (int i = 0; i < 11000; i++) {
// System.out.print(".");
if (processed.size() == tableProps.size()) {
success = true;
Expand All @@ -92,34 +93,33 @@ public static void main(String[] args) throws IOException, SQLException {
// System.out.println("-- already processed; continue");
continue;
}


List<String> weneed = deps.get(tpname);
boolean notFound = false;
if (weneed != null) {
for (String str : weneed) {
if (!processed.contains(str)) {
notFound = true;
break;

if (!ignoreDependency) {
List<String> weneed = deps.get(tpname);
boolean notFound = false;
if (weneed != null) {
for (String str : weneed) {
if (!processed.contains(str)) {
notFound = true;
break;
}
}
}
if (notFound)
continue;
}
if (notFound)
continue;

processed.add(tpname);

System.out.println("--------------------------------------------------");
System.out.println("--" + tpname);

TableProps tp = tpe.getValue();

ConArgs source = new ConArgs();
source.props = ini.srcProps;
source.schema = tp.schema;
source.table = tp.table;


System.out.println("--Schema comparison table:" + source.toFullTable());
ConArgs dest = new ConArgs();
dest.props = ini.destProps;
Expand All @@ -130,14 +130,13 @@ public static void main(String[] args) throws IOException, SQLException {
s.initMeta();
Con d = new Con(dest);
d.initMeta();

System.out.println("--Estimated Source row size:" + s.getRowSize());
System.out.println("--Estimated Destination row size:" + d.getRowSize());
//

System.out.println("--Source disk size(MB):" + s.getOnDiskSize());
System.out.println("--Destination disk size(MB):" + d.getOnDiskSize());


System.out.println("--Schema comparison begin");
String cs = s.compareSchema(d);
Expand All @@ -163,15 +162,13 @@ public static void main(String[] args) throws IOException, SQLException {
// System.out.println("--Source or destination table row count over limit ; Bypassing this table");
// continue;
// }


double inMB=s.getOnDiskSize()+d.getOnDiskSize();

double inMB = s.getOnDiskSize() + d.getOnDiskSize();
System.out.println("--Total disk size need:" + inMB);
if(inMB > ini.dataCompareDiskSizeLimitInMB) {
if (inMB > ini.dataCompareDiskSizeLimitInMB) {
System.out.println("--Memory need over limit ; Bypassing this table");
continue;
}


System.out.println("--Getting data");
s.getData();
Expand Down Expand Up @@ -204,11 +201,25 @@ public static void main(String[] args) throws IOException, SQLException {
// s.disconnect();
// d.disconnect();
}
if (i == 9998) {
System.out.println("----------------------------------------------------");
System.out.println("----------------------------------------------------");
System.out.println("--We will ignore dependency then");
System.out.println("--FAILED; CYCLIC DEPENDENCY");
System.out.println("--These are tables left...");
ignoreDependency = true;
for (String string : tableProps.keySet()) {
if (!processed.contains(string)) {
System.out.println("--" + string);
}
}
}
}
if (success) {
System.out.println("--END SUCCESS");
} else {
System.out.println("--FAILED; CYCLIC DEPENDENCY");
System.out.println("--END FAILED");

}

}
Expand Down

0 comments on commit b89cc87

Please sign in to comment.