/
IDataService.java
221 lines (147 loc) · 9.63 KB
/
IDataService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.service;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.sql.ISqlReadCursor;
import org.jumpmind.db.sql.ISqlRowMapper;
import org.jumpmind.db.sql.ISqlTransaction;
import org.jumpmind.symmetric.ext.IHeartbeatListener;
import org.jumpmind.symmetric.io.data.Batch;
import org.jumpmind.symmetric.io.data.CsvData;
import org.jumpmind.symmetric.load.IReloadGenerator;
import org.jumpmind.symmetric.model.AbstractBatch.Status;
import org.jumpmind.symmetric.model.Data;
import org.jumpmind.symmetric.model.DataEvent;
import org.jumpmind.symmetric.model.DataGap;
import org.jumpmind.symmetric.model.ExtractRequest;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.ProcessInfo;
import org.jumpmind.symmetric.model.TableReloadRequest;
import org.jumpmind.symmetric.model.TableReloadRequestKey;
import org.jumpmind.symmetric.model.TableReloadStatus;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.jumpmind.symmetric.model.TriggerRouter;
/**
* This service provides an API to access and update {@link Data}.
*/
public interface IDataService {
public void insertTableReloadRequest(ISqlTransaction transaction, TableReloadRequest request);
public void insertTableReloadRequest(TableReloadRequest request);
public TableReloadRequest getTableReloadRequest(TableReloadRequestKey key);
public TableReloadRequest getTableReloadRequest(long loadId);
public TableReloadRequest getTableReloadRequest(long loadId, String triggerId, String routerId);
public List<TableReloadRequest> getTableReloadRequestToProcess(final String sourceNodeId);
public List<TableReloadStatus> getTableReloadStatus();
public List<TableReloadStatus> getActiveTableReloadStatus();
public TableReloadStatus getTableReloadStatusByLoadId(long loadId);
public List<TableReloadStatus> getTableReloadStatusByTarget(String targetNodeId);
public void updateTableReloadStatusDataLoaded(ISqlTransaction transcation, long loadId, long batchId, int batchCount);
public int updateTableReloadRequestsCancelled(long loadId);
public int cancelTableReloadRequest(TableReloadRequest request);
public String reloadNode(String nodeId, boolean reverseLoad, String createBy);
public String reloadTable(String nodeId, String catalogName, String schemaName, String tableName);
public String reloadTable(String nodeId, String catalogName, String schemaName, String tableName, String overrideInitialLoadSelect);
public String reloadTableImmediate(String nodeId, String catalogName, String schemaName, String tableName,
String overrideInitialLoadSelect, String overrideChannelId);
public void reloadMissingForeignKeyRows(String nodeId, long dataId);
public void reloadMissingForeignKeyRowsReverse(String sourceNodeId, Table table, CsvData data, String channelId, boolean sendCorrectionToPeers);
/**
* Sends a SQL command to the remote node for execution by creating a SQL event that is synced like other data
*
* @param nodeId the remote node where the SQL statement will be executed
* @param catalogName used to find the sym_trigger entry for table that will be associated with this event
* @param schemaName used to find the sym_trigger entry for table that will be associated with this event
* @param tableName used to find the sym_trigger entry for table that will be associated with this event
* @param sql the SQL statement to run on the remote node database
* @return message string indicating success or error
*/
public String sendSQL(String nodeId, String catalogName, String schemaName, String tableName, String sql);
public String sendSQL(String nodeId, String sql);
public Map<Integer, ExtractRequest> insertReloadEvents(
Node targetNode, boolean reverse, List<TableReloadRequest> reloadRequests,
ProcessInfo processInfo, List<TriggerRouter> triggerRouters,
Map<Integer, ExtractRequest> extractRequests,
IReloadGenerator reloadGenerator);
public boolean insertReloadEvent(TableReloadRequest request, boolean deleteAtClient);
public long insertReloadEvent(ISqlTransaction transaction, Node targetNode,
TriggerRouter triggerRouter, TriggerHistory triggerHistory, String overrideInitialLoadSelect, boolean isLoad, long loadId, String createBy, Status status, long estimatedBatchRowCount);
public void sendScript(String nodeId, String script, boolean isLoad);
public boolean sendSchema(String nodeId, String catalogName, String schemaName,
String tableName, boolean isLoad);
/**
* Update {@link Node} information for this node and call {@link IHeartbeatListener}s.
*/
public void heartbeat(boolean force);
public void insertHeartbeatEvent(Node node, boolean isReload);
public long insertData(Data data);
public long insertData(ISqlTransaction transaction, final Data data);
public void insertDataEvents(ISqlTransaction transaction, List<DataEvent> events);
public void insertDataAndDataEventAndOutgoingBatch(Data data, String channelId, List<Node> nodes, boolean isLoad, long loadId, String createBy);
public long insertDataAndDataEventAndOutgoingBatch(ISqlTransaction transaction, Data data,
String nodeId, boolean isLoad, long loadId, String createBy, Status status, long estimatedBatchRowCount);
public long insertDataAndDataEventAndOutgoingBatch(Data data, String nodeId, boolean isLoad, long loadId, String createBy);
public void insertSqlEvent(ISqlTransaction transaction, Node targetNode, String sql, boolean isLoad, long loadId, String createBy);
public void insertSqlEvent(ISqlTransaction transaction, TriggerHistory history, String channelId, Node targetNode, String sql, boolean isLoad, long loadId, String createBy);
public void insertSqlEvent(Node targetNode, String sql, boolean isLoad, long loadId, String createBy);
public void insertScriptEvent(String channelId, Node targetNode, String script, boolean isLoad,
long loadId, String createBy);
public void insertScriptEvent(ISqlTransaction transaction, String channelId,
Node targetNode, String script, boolean isLoad, long loadId, String createBy);
public void insertCreateEvent(Node targetNode, TriggerHistory triggerHistory, String createBy);
public void insertCreateEvent(Node targetNode, TriggerHistory triggerHistory, boolean isLoad, long loadId, String createBy);
public void insertCreateEvent(ISqlTransaction transaction, Node targetNode, TriggerHistory triggerHistory, String channelId, boolean isLoad, long loadId, String createBy);
/**
* Count the number of data ids in a range
*/
public int countDataInRange(long firstDataId, long secondDataId);
public long countDataGaps();
public List<DataGap> findDataGapsUnchecked();
public List<DataGap> findDataGaps();
public Date findCreateTimeOfEvent(long dataId);
public Date findCreateTimeOfData(long dataId);
public Date findNextCreateTimeOfDataStartingAt(long dataId);
public Data createData(String catalogName, String schemaName, String tableName);
public Data createData(String catalogName, String schemaName, String tableName, String whereClause);
public Data createData(ISqlTransaction transaction, String catalogName, String schemaName, String tableName, String whereClause);
public ISqlRowMapper<Data> getDataMapper();
public List<Number> listDataIds(long batchId, String nodeId);
public List<Data> listData(long batchId, String nodeId, long startDataId, String channelId, int maxRowsToRetrieve);
public void insertDataGap(DataGap gap);
public void insertDataGap(ISqlTransaction transaction, DataGap gap);
public void insertDataGaps(ISqlTransaction transaction, Collection<DataGap> gaps);
public void deleteDataGap(ISqlTransaction transaction, DataGap gap);
public void deleteDataGaps(ISqlTransaction transaction, Collection<DataGap> gaps);
public void deleteAllDataGaps(ISqlTransaction transaction);
public void deleteDataGap(DataGap gap);
public void deleteCapturedConfigChannelData();
public boolean fixLastDataGap();
public long findMaxDataId();
public Data findData(long dataId);
public long findMinDataId();
public ISqlReadCursor<Data> selectDataFor(Batch batch);
public ISqlReadCursor<Data> selectDataFor(Long batchId, String channelId);
public ISqlReadCursor<Data> selectDataFor(Long batchId, String targetNodeId, boolean isContainsBigLob);
public Map<String, Date> getLastDataCaptureByChannel();
}