Skip to content

Commit

Permalink
Automatic code cleanup (#1)
Browse files Browse the repository at this point in the history
* Add gitignore

* Automatic code reformat

* Minor code cleaning
  • Loading branch information
martinboulais authored Aug 22, 2024
1 parent a2c846a commit b185af6
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 230 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
bin
AliDip2BK.jar
AliDip2BK.jar
.idea
STATE
AliDip2BK.iml
RunsHistory
3 changes: 1 addition & 2 deletions AliDip2BK.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#DNSnode=192.168.1.133
DNSnode=dipnsgpn1.cern.ch
DNSnode=dipnsdev.cern.ch
#in this file we list the Dip Data Providers to subscribe
DipDataProvidersSubscritionFile=TselectLHC.txt
# this option will list all the Data Providers than mach this pattern
Expand Down
72 changes: 27 additions & 45 deletions src/alice/dip/AliDip2BK.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*************
* cil
**************/
* cil
**************/

/*
* Main Class
*
* Main Class
*
*/

package alice.dip;
Expand All @@ -21,58 +21,40 @@
public class AliDip2BK implements Runnable {

public static String Version = "2.0 14-Nov-2023";
String confFile = "AliDip2BK.properties";

public static String DNSnode = "dipnsgpn1,dipnsgpn2";

public static String[] endFillCases = { "CUCU" };

public static String DNSnode = "dipnsdev.cern.ch";
public static String[] endFillCases = {"CUCU"};
public static boolean LIST_PARAM = false;
static public String LIST_PARAM_PAT = "*";

static public int DEBUG_LEVEL = 1;

static public String OUTPUT_FILE = null;

public static String BKURL = "http://aliecs-kafka-1.cern.ch:4000";
public static String BKURL = "http://localhost:4000";
public static String BKP_TOKEN = null;

public static boolean SAVE_PARAMETERS_HISTORY_PER_RUN = false;

public static String KEEP_RUNS_HISTORY_DIRECTORY = null;
public static String KEEP_FILLS_HISTORY_DIRECTORY = null;

public static String KEEP_STATE_DIR = "STATE/";

public static String bootstrapServers = "127.0.0.1:9092";
public static String KAFKAtopic_SOR = "aliecs.env_state.RUNNING";
public static String KAFKAtopic_EOR = "aliecs.env_leave_state.RUNNING";

public static String KAFKA_group_id = "AliDip";

public static String STORE_HIST_FILE_DIR = "HistFiles";
public String DipParametersFile = null;

public static boolean SIMULATE_DIP_EVENTS = false;

public static SimpleDateFormat myDateFormat = new SimpleDateFormat("dd-MM-yy HH:mm");
public static SimpleDateFormat logDateFormat = new SimpleDateFormat("dd-MM HH:mm:ss");

public static double DIFF_ENERGY = 5;
public static double DIFF_BETA = 0.001;
public static double DIFF_CURRENT = 5;

public static String ProgPath;
public String DipParametersFile = null;
String confFile = "AliDip2BK.properties";
DipClient client;
ProcData process;
BKwriter dbw;
KC_SOR kcs;
KC_EOR kce;

private long startDate;
private long stopDate;

public static String ProgPath;

public AliDip2BK() {

startDate = (new Date()).getTime();
Expand Down Expand Up @@ -107,11 +89,26 @@ public AliDip2BK() {

}

static public void log(int level, String module, String mess) {
if (level >= DEBUG_LEVEL) {
String date = logDateFormat.format((new Date()).getTime());

System.out.println("#" + level + " [" + date + "] " + module + " =>" + mess);
}
}

public static void main(String[] args) {

@SuppressWarnings("unused")
AliDip2BK service = new AliDip2BK();

}

public void run() {

int stat_count = 0;

for (;;) {
for (; ; ) {

try {
Thread.sleep(10000);
Expand Down Expand Up @@ -210,7 +207,7 @@ public void loadConf(String filename) {

} else {
log(4, "AliDip2BK.loadConf ",
" List DIP Data Providers Pattern is undefined ! The DIP broswer will not start ");
" List DIP Data Providers Pattern is undefined ! The DIP broswer will not start ");

}

Expand Down Expand Up @@ -300,14 +297,6 @@ public void loadConf(String filename) {

}

static public void log(int level, String module, String mess) {
if (level >= DEBUG_LEVEL) {
String date = logDateFormat.format((new Date()).getTime());

System.out.println("#" + level + " [" + date + "] " + module + " =>" + mess);
}
}

public void writeStat(String file, boolean final_report) {

String full_file = ProgPath + AliDip2BK.KEEP_STATE_DIR + file;
Expand Down Expand Up @@ -373,11 +362,4 @@ public void verifyDir(String name) {
}
}

public static void main(String[] args) {

@SuppressWarnings("unused")
AliDip2BK service = new AliDip2BK();

}

}
6 changes: 3 additions & 3 deletions src/alice/dip/AliceInfoObj.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*************
* cil
**************/
* cil
**************/
/*
* Keeps ALICE specific information
* Keeps ALICE specific information
*/
package alice.dip;

Expand Down
58 changes: 29 additions & 29 deletions src/alice/dip/BKwriter.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*************
* cil
**************/
* cil
**************/

/*
* This class is used to write the Dip information into the
* Bookkeeping Data Base
* This class is used to write the Dip information into the
* Bookkeeping Data Base
*/
package alice.dip;

Expand All @@ -23,9 +23,9 @@ public BKwriter() {
// path = getClass().getClassLoader().getResource(".").getPath();

httpClient = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_2)
.connectTimeout(Duration.ofSeconds(10))
.build();
.version(HttpClient.Version.HTTP_2)
.connectTimeout(Duration.ofSeconds(10))
.build();

}

Expand All @@ -35,7 +35,7 @@ public void X_InsertLHC(LhcInfoObj lhc) {

if (ok) {
AliDip2BK.log(3, "BKwriter.InserFill",
"INSERT FILL ... BUT Fill No=" + lhc.fillNo + " is in BK ... trying to update record");
"INSERT FILL ... BUT Fill No=" + lhc.fillNo + " is in BK ... trying to update record");
XUpdateFill(lhc);
return;
}
Expand All @@ -58,10 +58,10 @@ public void X_InsertLHC(LhcInfoObj lhc) {
furl += "?token=" + AliDip2BK.BKP_TOKEN;
}
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(furl))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(mydata))
.build();
.uri(URI.create(furl))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(mydata))
.build();

HttpResponse<String> response;

Expand All @@ -86,9 +86,9 @@ public boolean XTestFillNo(LhcInfoObj lhc) {
}

HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(furl))
.GET() // default
.build();
.uri(URI.create(furl))
.GET() // default
.build();

HttpResponse<String> response;
try {
Expand Down Expand Up @@ -127,9 +127,9 @@ public boolean TestRunNo(int N) {
}

HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(furl))
.GET() // default
.build();
.uri(URI.create(furl))
.GET() // default
.build();

HttpResponse<String> response;
try {
Expand All @@ -147,7 +147,7 @@ public boolean TestRunNo(int N) {

} else {
AliDip2BK.log(3, "BKwriter.TestRunNo",
" Reguest error =" + response.statusCode() + " Mesage=" + response.body());
" Reguest error =" + response.statusCode() + " Mesage=" + response.body());
return false;
}
} catch (Exception e) {
Expand Down Expand Up @@ -257,10 +257,10 @@ public void UpdateRun(RunInfoObj runObj) {
}

HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(furl))
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString(mydata))
.build();
.uri(URI.create(furl))
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString(mydata))
.build();

HttpResponse<String> response;
try {
Expand All @@ -270,7 +270,7 @@ public void UpdateRun(RunInfoObj runObj) {
AliDip2BK.log(2, "BKwriter.UpdateRun", "Succesful Update for RUN=" + runObj.RunNo);
} else {
AliDip2BK.log(3, "BKwriter.UpdateRun",
"ERROR for RUN=" + runObj.RunNo + " Code=" + +response.statusCode() + " Message=" + response.body());
"ERROR for RUN=" + runObj.RunNo + " Code=" + +response.statusCode() + " Message=" + response.body());
}

} catch (Exception e) {
Expand Down Expand Up @@ -340,10 +340,10 @@ public void XUpdateFill(LhcInfoObj cfill) {
}

HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(furl))
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString(mydata))
.build();
.uri(URI.create(furl))
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString(mydata))
.build();

HttpResponse<String> response;
try {
Expand All @@ -353,7 +353,7 @@ public void XUpdateFill(LhcInfoObj cfill) {
AliDip2BK.log(2, "BKwriter.UpdateFILL", "Succesful Update for FILL=" + cfill.fillNo);
} else {
AliDip2BK.log(3, "BKwriter.UpdateFILL",
"ERROR for FILL=" + cfill.fillNo + " Code=" + +response.statusCode() + " Message=" + response.body());
"ERROR for FILL=" + cfill.fillNo + " Code=" + +response.statusCode() + " Message=" + response.body());
}

} catch (Exception e) {
Expand Down
Loading

0 comments on commit b185af6

Please sign in to comment.