Skip to content

Commit b185af6

Browse files
Automatic code cleanup (#1)
* Add gitignore * Automatic code reformat * Minor code cleaning
1 parent a2c846a commit b185af6

16 files changed

+204
-230
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
bin
2-
AliDip2BK.jar
2+
AliDip2BK.jar
3+
.idea
4+
STATE
5+
AliDip2BK.iml
6+
RunsHistory

AliDip2BK.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#DNSnode=192.168.1.133
2-
DNSnode=dipnsgpn1.cern.ch
1+
DNSnode=dipnsdev.cern.ch
32
#in this file we list the Dip Data Providers to subscribe
43
DipDataProvidersSubscritionFile=TselectLHC.txt
54
# this option will list all the Data Providers than mach this pattern

src/alice/dip/AliDip2BK.java

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*************
2-
* cil
3-
**************/
2+
* cil
3+
**************/
44

55
/*
6-
* Main Class
7-
*
6+
* Main Class
7+
*
88
*/
99

1010
package alice.dip;
@@ -21,58 +21,40 @@
2121
public class AliDip2BK implements Runnable {
2222

2323
public static String Version = "2.0 14-Nov-2023";
24-
String confFile = "AliDip2BK.properties";
25-
26-
public static String DNSnode = "dipnsgpn1,dipnsgpn2";
27-
28-
public static String[] endFillCases = { "CUCU" };
29-
24+
public static String DNSnode = "dipnsdev.cern.ch";
25+
public static String[] endFillCases = {"CUCU"};
3026
public static boolean LIST_PARAM = false;
3127
static public String LIST_PARAM_PAT = "*";
32-
3328
static public int DEBUG_LEVEL = 1;
34-
3529
static public String OUTPUT_FILE = null;
36-
37-
public static String BKURL = "http://aliecs-kafka-1.cern.ch:4000";
30+
public static String BKURL = "http://localhost:4000";
3831
public static String BKP_TOKEN = null;
39-
4032
public static boolean SAVE_PARAMETERS_HISTORY_PER_RUN = false;
41-
4233
public static String KEEP_RUNS_HISTORY_DIRECTORY = null;
4334
public static String KEEP_FILLS_HISTORY_DIRECTORY = null;
44-
4535
public static String KEEP_STATE_DIR = "STATE/";
46-
4736
public static String bootstrapServers = "127.0.0.1:9092";
4837
public static String KAFKAtopic_SOR = "aliecs.env_state.RUNNING";
4938
public static String KAFKAtopic_EOR = "aliecs.env_leave_state.RUNNING";
50-
5139
public static String KAFKA_group_id = "AliDip";
52-
5340
public static String STORE_HIST_FILE_DIR = "HistFiles";
54-
public String DipParametersFile = null;
55-
5641
public static boolean SIMULATE_DIP_EVENTS = false;
57-
5842
public static SimpleDateFormat myDateFormat = new SimpleDateFormat("dd-MM-yy HH:mm");
5943
public static SimpleDateFormat logDateFormat = new SimpleDateFormat("dd-MM HH:mm:ss");
60-
6144
public static double DIFF_ENERGY = 5;
6245
public static double DIFF_BETA = 0.001;
6346
public static double DIFF_CURRENT = 5;
64-
47+
public static String ProgPath;
48+
public String DipParametersFile = null;
49+
String confFile = "AliDip2BK.properties";
6550
DipClient client;
6651
ProcData process;
6752
BKwriter dbw;
6853
KC_SOR kcs;
6954
KC_EOR kce;
70-
7155
private long startDate;
7256
private long stopDate;
7357

74-
public static String ProgPath;
75-
7658
public AliDip2BK() {
7759

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

10890
}
10991

92+
static public void log(int level, String module, String mess) {
93+
if (level >= DEBUG_LEVEL) {
94+
String date = logDateFormat.format((new Date()).getTime());
95+
96+
System.out.println("#" + level + " [" + date + "] " + module + " =>" + mess);
97+
}
98+
}
99+
100+
public static void main(String[] args) {
101+
102+
@SuppressWarnings("unused")
103+
AliDip2BK service = new AliDip2BK();
104+
105+
}
106+
110107
public void run() {
111108

112109
int stat_count = 0;
113110

114-
for (;;) {
111+
for (; ; ) {
115112

116113
try {
117114
Thread.sleep(10000);
@@ -210,7 +207,7 @@ public void loadConf(String filename) {
210207

211208
} else {
212209
log(4, "AliDip2BK.loadConf ",
213-
" List DIP Data Providers Pattern is undefined ! The DIP broswer will not start ");
210+
" List DIP Data Providers Pattern is undefined ! The DIP broswer will not start ");
214211

215212
}
216213

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

301298
}
302299

303-
static public void log(int level, String module, String mess) {
304-
if (level >= DEBUG_LEVEL) {
305-
String date = logDateFormat.format((new Date()).getTime());
306-
307-
System.out.println("#" + level + " [" + date + "] " + module + " =>" + mess);
308-
}
309-
}
310-
311300
public void writeStat(String file, boolean final_report) {
312301

313302
String full_file = ProgPath + AliDip2BK.KEEP_STATE_DIR + file;
@@ -373,11 +362,4 @@ public void verifyDir(String name) {
373362
}
374363
}
375364

376-
public static void main(String[] args) {
377-
378-
@SuppressWarnings("unused")
379-
AliDip2BK service = new AliDip2BK();
380-
381-
}
382-
383365
}

src/alice/dip/AliceInfoObj.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*************
2-
* cil
3-
**************/
2+
* cil
3+
**************/
44
/*
5-
* Keeps ALICE specific information
5+
* Keeps ALICE specific information
66
*/
77
package alice.dip;
88

src/alice/dip/BKwriter.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*************
2-
* cil
3-
**************/
2+
* cil
3+
**************/
44

55
/*
6-
* This class is used to write the Dip information into the
7-
* Bookkeeping Data Base
6+
* This class is used to write the Dip information into the
7+
* Bookkeeping Data Base
88
*/
99
package alice.dip;
1010

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

2525
httpClient = HttpClient.newBuilder()
26-
.version(HttpClient.Version.HTTP_2)
27-
.connectTimeout(Duration.ofSeconds(10))
28-
.build();
26+
.version(HttpClient.Version.HTTP_2)
27+
.connectTimeout(Duration.ofSeconds(10))
28+
.build();
2929

3030
}
3131

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

3636
if (ok) {
3737
AliDip2BK.log(3, "BKwriter.InserFill",
38-
"INSERT FILL ... BUT Fill No=" + lhc.fillNo + " is in BK ... trying to update record");
38+
"INSERT FILL ... BUT Fill No=" + lhc.fillNo + " is in BK ... trying to update record");
3939
XUpdateFill(lhc);
4040
return;
4141
}
@@ -58,10 +58,10 @@ public void X_InsertLHC(LhcInfoObj lhc) {
5858
furl += "?token=" + AliDip2BK.BKP_TOKEN;
5959
}
6060
HttpRequest request = HttpRequest.newBuilder()
61-
.uri(URI.create(furl))
62-
.header("Content-Type", "application/json")
63-
.method("POST", HttpRequest.BodyPublishers.ofString(mydata))
64-
.build();
61+
.uri(URI.create(furl))
62+
.header("Content-Type", "application/json")
63+
.method("POST", HttpRequest.BodyPublishers.ofString(mydata))
64+
.build();
6565

6666
HttpResponse<String> response;
6767

@@ -86,9 +86,9 @@ public boolean XTestFillNo(LhcInfoObj lhc) {
8686
}
8787

8888
HttpRequest request = HttpRequest.newBuilder()
89-
.uri(URI.create(furl))
90-
.GET() // default
91-
.build();
89+
.uri(URI.create(furl))
90+
.GET() // default
91+
.build();
9292

9393
HttpResponse<String> response;
9494
try {
@@ -127,9 +127,9 @@ public boolean TestRunNo(int N) {
127127
}
128128

129129
HttpRequest request = HttpRequest.newBuilder()
130-
.uri(URI.create(furl))
131-
.GET() // default
132-
.build();
130+
.uri(URI.create(furl))
131+
.GET() // default
132+
.build();
133133

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

148148
} else {
149149
AliDip2BK.log(3, "BKwriter.TestRunNo",
150-
" Reguest error =" + response.statusCode() + " Mesage=" + response.body());
150+
" Reguest error =" + response.statusCode() + " Mesage=" + response.body());
151151
return false;
152152
}
153153
} catch (Exception e) {
@@ -257,10 +257,10 @@ public void UpdateRun(RunInfoObj runObj) {
257257
}
258258

259259
HttpRequest request = HttpRequest.newBuilder()
260-
.uri(URI.create(furl))
261-
.header("Content-Type", "application/json")
262-
.method("PATCH", HttpRequest.BodyPublishers.ofString(mydata))
263-
.build();
260+
.uri(URI.create(furl))
261+
.header("Content-Type", "application/json")
262+
.method("PATCH", HttpRequest.BodyPublishers.ofString(mydata))
263+
.build();
264264

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

276276
} catch (Exception e) {
@@ -340,10 +340,10 @@ public void XUpdateFill(LhcInfoObj cfill) {
340340
}
341341

342342
HttpRequest request = HttpRequest.newBuilder()
343-
.uri(URI.create(furl))
344-
.header("Content-Type", "application/json")
345-
.method("PATCH", HttpRequest.BodyPublishers.ofString(mydata))
346-
.build();
343+
.uri(URI.create(furl))
344+
.header("Content-Type", "application/json")
345+
.method("PATCH", HttpRequest.BodyPublishers.ofString(mydata))
346+
.build();
347347

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

359359
} catch (Exception e) {

0 commit comments

Comments
 (0)