Skip to content

Commit a054c80

Browse files
author
chengyitian
committed
AJ-605: merge EventSender constructor and connect;
1 parent 051c4eb commit a054c80

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

src/com/xxdb/streaming/client/cep/EventSender.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,9 @@ public class EventSender {
1212
private String insertScript;
1313
private EventHandler eventHandler;
1414
private DBConnection conn;
15-
private boolean isConnected;
1615

17-
public EventSender(List<EventSchema> eventSchemas, List<String> eventTimeKeys, List<String> commonKeys) {
16+
public EventSender(DBConnection conn, String tableName, List<EventSchema> eventSchemas, List<String> eventTimeKeys, List<String> commonKeys) throws IOException {
1817
this.eventHandler = new EventHandler(eventSchemas, eventTimeKeys, commonKeys);
19-
this.isConnected = false;
20-
}
21-
22-
public void connect(DBConnection conn, String tableName) throws IOException {
23-
if (this.isConnected)
24-
throw new RuntimeException("The eventSender has already been called.");
25-
26-
if (!conn.isConnected())
27-
throw new RuntimeException("The connection to dolphindb has not been established.");
28-
2918
this.conn = conn;
3019

3120
String sql = "select top 0 * from " + tableName;
@@ -35,13 +24,9 @@ public void connect(DBConnection conn, String tableName) throws IOException {
3524
throw new RuntimeException(errMsg.toString());
3625

3726
this.insertScript = "tableInsert{" + tableName + "}";
38-
this.isConnected = true;
3927
}
4028

4129
public void sendEvent(String eventType, List<Entity> attributes) {
42-
if (!isConnected)
43-
throw new RuntimeException("This eventSender has not connected to the dolphindb");
44-
4530
List<Entity> args = new ArrayList<>();
4631
StringBuilder errMsg = new StringBuilder();
4732

@@ -55,8 +40,4 @@ public void sendEvent(String eventType, List<Entity> attributes) {
5540
}
5641
}
5742

58-
public static EventSender createEventSender(List<EventSchema> eventSchemas, List<String> eventTimeKeys, List<String> commonKeys) {
59-
return new EventSender(eventSchemas, eventTimeKeys, commonKeys);
60-
}
61-
6243
}

0 commit comments

Comments
 (0)