added logic for using two servers UCB and NABARD

This commit is contained in:
2025-05-11 18:07:17 +05:30
parent 34d1647126
commit d631fa95f7
2 changed files with 57 additions and 18 deletions

View File

@@ -10,7 +10,8 @@ public class Main {
public static void main(String[] args) {
String user = "";
String password = "";
String host = "";
String hostUcb = "";
String hostNabard = "";
String local_folder_path = "";
String local_archive_path = "";
String local_report_path = "";
@@ -32,7 +33,8 @@ public class Main {
}
prop.load(input);
host = prop.getProperty("REMOTE_HOST");
hostUcb = prop.getProperty("REMOTE_HOST_UCB");
hostNabard = prop.getProperty("REMOTE_HOST_NABARD");
user = prop.getProperty("REMOTE_USER");
password = prop.getProperty("REMOTE_PASS");
port = Integer.parseInt(prop.getProperty("REMOTE_PORT"));
@@ -49,8 +51,10 @@ public class Main {
System.out.println("Config Properties read:");
System.out.println(
"REMOTE_HOST: "
+ host
"REMOTE_HOST_UCB: "
+ hostUcb
+ "\nREMOTE_HOST_NABARD: "
+ hostNabard
+ "\nREMOTE_USER: "
+ user
+ "\nREMOTE_PASS: "
@@ -74,27 +78,48 @@ public class Main {
new SendLocalfile(
user,
password,
host,
hostUcb,
hostNabard,
local_folder_path,
remote_file_path,
transfer_protocol,
port,
local_archive_path);
FetchReportFile fetch =
FetchReportFile fetchUcb =
new FetchReportFile(
user,
password,
host,
hostUcb,
local_report_path,
remote_report_path,
transfer_protocol,
port,
remote_report_pattern);
FetchReportFile fetchFailed =
FetchReportFile fetchNabard =
new FetchReportFile(
user,
password,
host,
hostNabard,
local_report_path,
remote_report_path,
transfer_protocol,
port,
remote_report_pattern);
FetchReportFile fetchFailedUcb =
new FetchReportFile(
user,
password,
hostUcb,
local_failed_path,
remote_failed_path,
transfer_protocol,
port,
remote_report_pattern);
FetchReportFile fetchFailedNabard =
new FetchReportFile(
user,
password,
hostNabard,
local_failed_path,
remote_failed_path,
transfer_protocol,
@@ -105,8 +130,10 @@ public class Main {
while (true) {
System.out.println("___________________________________________________");
send.sendFiles();
fetch.fetchFiles();
fetchFailed.fetchFiles();
fetchUcb.fetchFiles();
fetchNabard.fetchFiles();
fetchFailedUcb.fetchFiles();
fetchFailedNabard.fetchFiles();
System.out.println("Sleeping for:" + sleep + " Minutes");
System.out.println("___________________________________________________");
TimeUnit.MINUTES.sleep(sleep);
@@ -118,4 +145,4 @@ public class Main {
return;
}
}
}
}

View File

@@ -7,7 +7,8 @@ import com.sendFile.protocol.SSH.SSHProtocol;
public class SendLocalfile {
String user;
String password;
String host;
String hostUcb;
String hostNabard;
String local_folder_path;
String archive_path;
String remote_file_path;
@@ -17,7 +18,8 @@ public class SendLocalfile {
public SendLocalfile(
String user,
String password,
String host,
String hostUcb,
String hostNabard,
String local_folder_path,
String remote_file_path,
String transfer_protocol,
@@ -25,7 +27,8 @@ public class SendLocalfile {
String archivePath) {
this.user = user;
this.password = password;
this.host = host;
this.hostUcb = hostUcb;
this.hostNabard = hostNabard;
this.local_folder_path = local_folder_path;
this.remote_file_path = remote_file_path;
this.transfer_protocol = transfer_protocol;
@@ -40,13 +43,22 @@ public class SendLocalfile {
for (File file : listOfFiles) {
if (file.isFile()) {
System.out.println("Going to send file: " + file.getAbsolutePath());
String bankCode = file.getName().split("-")[0];
String bankHost = "";
if(bankCode.equals("0005") || bankCode.equals("0021")) {
bankHost = hostNabard;
} else {
bankHost = hostUcb;
}
if (this.transfer_protocol.equals("SSH")) {
SSHProtocol ssh =
new SSHProtocol(
this.user,
this.password,
this.host,
bankHost,
this.port,
file.getAbsolutePath(),
this.remote_file_path,
@@ -59,7 +71,7 @@ public class SendLocalfile {
new FTPProtocol(
this.user,
this.password,
this.host,
bankHost,
this.port,
file.getAbsolutePath(),
this.remote_file_path,
@@ -73,4 +85,4 @@ public class SendLocalfile {
}
}
}
}
}