-
Notifications
You must be signed in to change notification settings - Fork 160
/
MessageStoreFacade.java
535 lines (464 loc) · 23.9 KB
/
MessageStoreFacade.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
/*******************************************************************************
* Copyright (c) 2016, 2021 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.service.datastore.internal;
import com.codahale.metrics.Counter;
import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.KapuaIllegalArgumentException;
import org.eclipse.kapua.commons.cache.LocalCache;
import org.eclipse.kapua.commons.metric.MetricServiceFactory;
import org.eclipse.kapua.commons.metric.MetricsService;
import org.eclipse.kapua.commons.util.ArgumentValidator;
import org.eclipse.kapua.commons.util.KapuaDateUtils;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.message.KapuaMessage;
import org.eclipse.kapua.message.device.data.KapuaDataChannel;
import org.eclipse.kapua.message.internal.device.data.KapuaDataChannelImpl;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.datastore.exception.DatastoreDisabledException;
import org.eclipse.kapua.service.datastore.internal.mediator.ConfigurationException;
import org.eclipse.kapua.service.datastore.internal.mediator.DatastoreChannel;
import org.eclipse.kapua.service.datastore.internal.mediator.DatastoreUtils;
import org.eclipse.kapua.service.datastore.internal.mediator.MessageField;
import org.eclipse.kapua.service.datastore.internal.mediator.MessageInfo;
import org.eclipse.kapua.service.datastore.internal.mediator.MessageStoreConfiguration;
import org.eclipse.kapua.service.datastore.internal.mediator.MessageStoreMediator;
import org.eclipse.kapua.service.datastore.internal.mediator.Metric;
import org.eclipse.kapua.service.datastore.internal.model.DataIndexBy;
import org.eclipse.kapua.service.datastore.internal.model.DatastoreMessageImpl;
import org.eclipse.kapua.service.datastore.internal.model.MessageListResultImpl;
import org.eclipse.kapua.service.datastore.internal.model.query.ChannelInfoQueryImpl;
import org.eclipse.kapua.service.datastore.internal.model.query.ClientInfoQueryImpl;
import org.eclipse.kapua.service.datastore.internal.model.query.MessageQueryImpl;
import org.eclipse.kapua.service.datastore.internal.model.query.MetricInfoQueryImpl;
import org.eclipse.kapua.service.datastore.internal.model.query.predicate.ChannelMatchPredicateImpl;
import org.eclipse.kapua.service.datastore.internal.schema.ChannelInfoSchema;
import org.eclipse.kapua.service.datastore.internal.schema.ClientInfoSchema;
import org.eclipse.kapua.service.datastore.internal.schema.MessageSchema;
import org.eclipse.kapua.service.datastore.internal.schema.Metadata;
import org.eclipse.kapua.service.datastore.internal.schema.MetricInfoSchema;
import org.eclipse.kapua.service.datastore.internal.schema.SchemaUtil;
import org.eclipse.kapua.service.datastore.model.ChannelInfo;
import org.eclipse.kapua.service.datastore.model.ClientInfo;
import org.eclipse.kapua.service.datastore.model.DatastoreMessage;
import org.eclipse.kapua.service.datastore.model.MessageListResult;
import org.eclipse.kapua.service.datastore.model.MetricInfo;
import org.eclipse.kapua.service.datastore.model.query.MessageQuery;
import org.eclipse.kapua.service.elasticsearch.client.exception.ClientException;
import org.eclipse.kapua.service.elasticsearch.client.exception.QueryMappingException;
import org.eclipse.kapua.service.elasticsearch.client.model.InsertRequest;
import org.eclipse.kapua.service.elasticsearch.client.model.InsertResponse;
import org.eclipse.kapua.service.elasticsearch.client.model.ResultList;
import org.eclipse.kapua.service.elasticsearch.client.model.TypeDescriptor;
import org.eclipse.kapua.service.storable.exception.MappingException;
import org.eclipse.kapua.service.storable.model.id.StorableId;
import org.eclipse.kapua.service.storable.model.id.StorableIdFactory;
import org.eclipse.kapua.service.storable.model.query.StorableFetchStyle;
import org.eclipse.kapua.service.storable.model.query.predicate.IdsPredicate;
import org.eclipse.kapua.service.storable.model.query.predicate.StorablePredicateFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* Message store facade
*
* @since 1.0.0
*/
public final class MessageStoreFacade extends AbstractRegistryFacade {
private static final Logger LOG = LoggerFactory.getLogger(MessageStoreFacade.class);
private static final KapuaLocator LOCATOR = KapuaLocator.getInstance();
private static final StorableIdFactory STORABLE_ID_FACTORY = LOCATOR.getFactory(StorableIdFactory.class);
private static final StorablePredicateFactory STORABLE_PREDICATE_FACTORY = LOCATOR.getFactory(StorablePredicateFactory.class);
private final Counter metricMessagesAlreadyInTheDatastoreCount;
private final MessageStoreMediator mediator;
private static final String QUERY = "query";
private static final String QUERY_SCOPE_ID = "query.scopeId";
private static final String SCOPE_ID = "scopeId";
/**
* Constructs the message store facade
*
* @param confProvider
* @param mediator
* @since 1.0.0
*/
public MessageStoreFacade(ConfigurationProvider confProvider, MessageStoreMediator mediator) {
super(confProvider);
this.mediator = mediator;
MetricsService metricService = MetricServiceFactory.getInstance();
metricMessagesAlreadyInTheDatastoreCount = metricService.getCounter(DataStoreDriverMetrics.METRIC_MODULE_NAME, DataStoreDriverMetrics.METRIC_COMPONENT_NAME, DataStoreDriverMetrics.METRIC_STORE, DataStoreDriverMetrics.METRIC_MESSAGES, DataStoreDriverMetrics.METRIC_ALREADY_IN_THE_DATASTORE, DataStoreDriverMetrics.METRIC_COUNT);
}
/**
* Store a message
*
* @param message
* @return
* @throws KapuaIllegalArgumentException
* @throws ConfigurationException
* @throws ClientException
*/
public StorableId store(KapuaMessage<?, ?> message, String messageId, boolean newInsert)
throws KapuaIllegalArgumentException,
DatastoreDisabledException,
ConfigurationException,
ClientException, MappingException {
ArgumentValidator.notNull(message, "message");
ArgumentValidator.notNull(message.getScopeId(), SCOPE_ID);
ArgumentValidator.notNull(message.getReceivedOn(), "receivedOn");
ArgumentValidator.notNull(messageId, "messageId");
// Define data TTL
if (!isDatastoreServiceEnabled(message.getScopeId())) {
throw new DatastoreDisabledException(message.getScopeId());
}
Date capturedOn = message.getCapturedOn();
// Overwrite timestamp if necessary
// Use the account service plan to determine whether we will give
// precede to the device time
MessageStoreConfiguration accountServicePlan = getConfigProvider().getConfiguration(message.getScopeId());
long indexedOn = KapuaDateUtils.getKapuaSysDate().toEpochMilli();
if (DataIndexBy.DEVICE_TIMESTAMP.equals(accountServicePlan.getDataIndexBy())) {
if (capturedOn != null) {
indexedOn = capturedOn.getTime();
} else {
LOG.debug("The account is set to use, as date indexing, the device timestamp but the device timestamp is null! Current system date will be used to indexing the message by date!");
}
}
// Extract schema metadata
Metadata schemaMetadata = mediator.getMetadata(message.getScopeId(), indexedOn);
Date indexedOnDate = new Date(indexedOn);
String indexName = schemaMetadata.getDataIndexName();
TypeDescriptor typeDescriptor = new TypeDescriptor(indexName, MessageSchema.MESSAGE_TYPE_NAME);
if (!newInsert) {
DatastoreMessage datastoreMessage = find(message.getScopeId(), STORABLE_ID_FACTORY.newStorableId(messageId), StorableFetchStyle.SOURCE_SELECT);
if (datastoreMessage != null) {
LOG.debug("Message with datatstore id '{}' already found", messageId);
metricMessagesAlreadyInTheDatastoreCount.inc();
return STORABLE_ID_FACTORY.newStorableId(messageId);
}
}
// Save message (the big one)
DatastoreMessage messageToStore = convertTo(message, messageId);
messageToStore.setTimestamp(indexedOnDate);
InsertRequest insertRequest = new InsertRequest(messageToStore.getDatastoreId().toString(), typeDescriptor, messageToStore);
// Possibly update the schema with new metric mappings
Map<String, Metric> metrics = new HashMap<>();
if (message.getPayload() != null && message.getPayload().getMetrics() != null && !message.getPayload().getMetrics().isEmpty()) {
Map<String, Object> messageMetrics = message.getPayload().getMetrics();
for (Map.Entry<String, Object> messageMetric : messageMetrics.entrySet()) {
String metricName = DatastoreUtils.normalizeMetricName(messageMetric.getKey());
String clientMetricType = DatastoreUtils.getClientMetricFromType(messageMetric.getValue().getClass());
Metric metric = new Metric(metricName, clientMetricType);
// each metric is potentially a dynamic field so report it a new mapping
String mappedName = DatastoreUtils.getMetricValueQualifier(metricName, clientMetricType);
metrics.put(mappedName, metric);
}
}
try {
mediator.onUpdatedMappings(message.getScopeId(), indexedOn, metrics);
} catch (KapuaException e) {
e.printStackTrace();
}
InsertResponse insertResponse = getElasticsearchClient().insert(insertRequest);
messageToStore.setDatastoreId(STORABLE_ID_FACTORY.newStorableId(insertResponse.getId()));
MessageInfo messageInfo = getConfigProvider().getInfo(message.getScopeId());
mediator.onAfterMessageStore(messageInfo, messageToStore);
return STORABLE_ID_FACTORY.newStorableId(insertResponse.getId());
}
/**
* Delete message by identifier.<br>
* <b>Be careful using this function since it doesn't guarantee the datastore consistency.<br>
* It just deletes the message by id without checking the consistency of the registries.</b>
*
* @param scopeId
* @param id
* @throws KapuaIllegalArgumentException
* @throws ConfigurationException
* @throws ClientException
*/
public void delete(KapuaId scopeId, StorableId id)
throws KapuaIllegalArgumentException,
ConfigurationException,
ClientException {
ArgumentValidator.notNull(scopeId, SCOPE_ID);
ArgumentValidator.notNull(id, "id");
if (!isDatastoreServiceEnabled(scopeId)) {
LOG.debug("Storage not enabled for account {}, return", scopeId);
return;
}
// get the index by finding the object by id
DatastoreMessage messageToBeDeleted = find(scopeId, id, StorableFetchStyle.FIELDS);
if (messageToBeDeleted != null) {
Metadata schemaMetadata = null;
try {
schemaMetadata = mediator.getMetadata(scopeId, messageToBeDeleted.getTimestamp().getTime());
} catch (KapuaException e) {
e.printStackTrace();
}
String indexName = schemaMetadata.getDataIndexName();
TypeDescriptor typeDescriptor = new TypeDescriptor(indexName, MessageSchema.MESSAGE_TYPE_NAME);
getElasticsearchClient().delete(typeDescriptor, id.toString());
} else {
LOG.warn("Cannot find the message to be deleted. scopeId: '{}' - id: '{}'", scopeId, id);
}
// otherwise no message to be deleted found
}
/**
* Find message by identifier
*
* @param scopeId
* @param id
* @param fetchStyle
* @return
* @throws KapuaIllegalArgumentException
* @throws QueryMappingException
* @throws ClientException
*/
public DatastoreMessage find(KapuaId scopeId, StorableId id, StorableFetchStyle fetchStyle)
throws KapuaIllegalArgumentException, ClientException {
ArgumentValidator.notNull(scopeId, SCOPE_ID);
ArgumentValidator.notNull(id, "id");
ArgumentValidator.notNull(fetchStyle, "fetchStyle");
MessageQueryImpl idsQuery = new MessageQueryImpl(scopeId);
idsQuery.setLimit(1);
IdsPredicate idsPredicate = STORABLE_PREDICATE_FACTORY.newIdsPredicate(MessageSchema.MESSAGE_TYPE_NAME);
idsPredicate.addId(id);
idsQuery.setPredicate(idsPredicate);
String indexName = SchemaUtil.getDataIndexName(scopeId);
TypeDescriptor typeDescriptor = new TypeDescriptor(indexName, MessageSchema.MESSAGE_TYPE_NAME);
return getElasticsearchClient().find(typeDescriptor, idsQuery, DatastoreMessage.class);
}
/**
* Find messages matching the given query
*
* @param query
* @return
* @throws KapuaIllegalArgumentException
* @throws ConfigurationException
* @throws QueryMappingException
* @throws ClientException
*/
public MessageListResult query(MessageQuery query)
throws KapuaIllegalArgumentException,
ConfigurationException,
ClientException {
ArgumentValidator.notNull(query, QUERY);
ArgumentValidator.notNull(query.getScopeId(), QUERY_SCOPE_ID);
if (!isDatastoreServiceEnabled(query.getScopeId())) {
LOG.debug("Storage not enabled for account {}, returning empty result", query.getScopeId());
return new MessageListResultImpl();
}
String dataIndexName = SchemaUtil.getDataIndexName(query.getScopeId());
TypeDescriptor typeDescriptor = new TypeDescriptor(dataIndexName, MessageSchema.MESSAGE_TYPE_NAME);
MessageListResult result = new MessageListResultImpl(getElasticsearchClient().query(typeDescriptor, query, DatastoreMessage.class));
setLimitExceed(query, result);
return result;
}
/**
* Get messages count matching the given query
*
* @param query
* @return
* @throws KapuaIllegalArgumentException
* @throws ConfigurationException
* @throws ClientException
*/
public long count(MessageQuery query)
throws KapuaIllegalArgumentException,
ConfigurationException,
ClientException {
ArgumentValidator.notNull(query, QUERY);
ArgumentValidator.notNull(query.getScopeId(), QUERY_SCOPE_ID);
if (!isDatastoreServiceEnabled(query.getScopeId())) {
LOG.debug("Storage not enabled for account {}, returning empty result", query.getScopeId());
return 0;
}
String indexName = SchemaUtil.getDataIndexName(query.getScopeId());
TypeDescriptor typeDescriptor = new TypeDescriptor(indexName, MessageSchema.MESSAGE_TYPE_NAME);
return getElasticsearchClient().count(typeDescriptor, query);
}
/**
* Delete messages count matching the given query.<br>
* <b>Be careful using this function since it doesn't guarantee the datastore consistency.<br>
* It just deletes the messages that matching the query without checking the consistency of the registries.</b>
*
* @param query
* @throws KapuaIllegalArgumentException
* @throws ConfigurationException
* @throws ClientException
*/
public void delete(MessageQuery query)
throws KapuaIllegalArgumentException,
ConfigurationException,
ClientException {
ArgumentValidator.notNull(query, QUERY);
ArgumentValidator.notNull(query.getScopeId(), QUERY_SCOPE_ID);
if (!isDatastoreServiceEnabled(query.getScopeId())) {
LOG.debug("Storage not enabled for account {}, skipping delete", query.getScopeId());
return;
}
String indexName = SchemaUtil.getDataIndexName(query.getScopeId());
TypeDescriptor typeDescriptor = new TypeDescriptor(indexName, MessageSchema.MESSAGE_TYPE_NAME);
getElasticsearchClient().deleteByQuery(typeDescriptor, query);
}
// TODO cache will not be reset from the client code it should be automatically reset
// after some time.
private void resetCache(KapuaId scopeId, KapuaId deviceId, String channel, String clientId) throws Exception {
boolean isAnyClientId;
boolean isClientToDelete = false;
String semTopic;
if (channel != null) {
// determine if we should delete an client if topic = account/clientId/#
isAnyClientId = isAnyClientId(channel);
semTopic = channel;
if (semTopic.isEmpty() && !isAnyClientId) {
isClientToDelete = true;
}
} else {
isClientToDelete = true;
}
// Find all topics
String dataIndexName = SchemaUtil.getDataIndexName(scopeId);
int pageSize = 1000;
int offset = 0;
long totalHits = 1;
MetricInfoQueryImpl metricQuery = new MetricInfoQueryImpl(scopeId);
metricQuery.setLimit(pageSize + 1);
metricQuery.setOffset(offset);
ChannelMatchPredicateImpl channelPredicate = new ChannelMatchPredicateImpl(MessageField.CHANNEL, channel);
metricQuery.setPredicate(channelPredicate);
// Remove metrics
while (totalHits > 0) {
TypeDescriptor typeDescriptor = new TypeDescriptor(dataIndexName, MetricInfoSchema.METRIC_TYPE_NAME);
ResultList<MetricInfo> metrics = getElasticsearchClient().query(typeDescriptor, metricQuery, MetricInfo.class);
totalHits = metrics.getTotalCount();
LocalCache<String, Boolean> metricsCache = DatastoreCacheManager.getInstance().getMetricsCache();
long toBeProcessed = totalHits > pageSize ? pageSize : totalHits;
for (int i = 0; i < toBeProcessed; i++) {
String id = metrics.getResult().get(i).getId().toString();
if (metricsCache.get(id)) {
metricsCache.remove(id);
}
}
if (totalHits > pageSize) {
offset += pageSize + 1;
}
}
LOG.debug("Removed cached channel metrics for: {}", channel);
TypeDescriptor typeMetricDescriptor = new TypeDescriptor(dataIndexName, MetricInfoSchema.METRIC_TYPE_NAME);
getElasticsearchClient().deleteByQuery(typeMetricDescriptor, metricQuery);
LOG.debug("Removed channel metrics for: {}", channel);
ChannelInfoQueryImpl channelQuery = new ChannelInfoQueryImpl(scopeId);
channelQuery.setLimit(pageSize + 1);
channelQuery.setOffset(offset);
channelPredicate = new ChannelMatchPredicateImpl(MessageField.CHANNEL, channel);
channelQuery.setPredicate(channelPredicate);
// Remove channel
offset = 0;
totalHits = 1;
while (totalHits > 0) {
TypeDescriptor typeDescriptor = new TypeDescriptor(dataIndexName, ChannelInfoSchema.CHANNEL_TYPE_NAME);
ResultList<ChannelInfo> channels = getElasticsearchClient().query(typeDescriptor, channelQuery, ChannelInfo.class);
totalHits = channels.getTotalCount();
LocalCache<String, Boolean> channelsCache = DatastoreCacheManager.getInstance().getChannelsCache();
long toBeProcessed = totalHits > pageSize ? pageSize : totalHits;
for (int i = 0; i < toBeProcessed; i++) {
String id = channels.getResult().get(0).getId().toString();
if (channelsCache.get(id)) {
channelsCache.remove(id);
}
}
if (totalHits > pageSize) {
offset += pageSize + 1;
}
}
LOG.debug("Removed cached channels for: {}", channel);
TypeDescriptor typeChannelDescriptor = new TypeDescriptor(dataIndexName, ChannelInfoSchema.CHANNEL_TYPE_NAME);
getElasticsearchClient().deleteByQuery(typeChannelDescriptor, channelQuery);
LOG.debug("Removed channels for: {}", channel);
// Remove client
if (isClientToDelete) {
ClientInfoQueryImpl clientInfoQuery = new ClientInfoQueryImpl(scopeId);
clientInfoQuery.setLimit(pageSize + 1);
clientInfoQuery.setOffset(offset);
channelPredicate = new ChannelMatchPredicateImpl(MessageField.CHANNEL, channel);
clientInfoQuery.setPredicate(channelPredicate);
offset = 0;
totalHits = 1;
while (totalHits > 0) {
TypeDescriptor typeDescriptor = new TypeDescriptor(dataIndexName, ClientInfoSchema.CLIENT_TYPE_NAME);
ResultList<ClientInfo> clients = getElasticsearchClient().query(typeDescriptor, clientInfoQuery, ClientInfo.class);
totalHits = clients.getTotalCount();
LocalCache<String, Boolean> clientsCache = DatastoreCacheManager.getInstance().getClientsCache();
long toBeProcessed = totalHits > pageSize ? pageSize : totalHits;
for (int i = 0; i < toBeProcessed; i++) {
String id = clients.getResult().get(i).getId().toString();
if (clientsCache.get(id)) {
clientsCache.remove(id);
}
}
if (totalHits > pageSize) {
offset += pageSize + 1;
}
}
LOG.debug("Removed cached clients for: {}", channel);
TypeDescriptor typeClientDescriptor = new TypeDescriptor(dataIndexName, ClientInfoSchema.CLIENT_TYPE_NAME);
getElasticsearchClient().deleteByQuery(typeClientDescriptor, clientInfoQuery);
LOG.debug("Removed clients for: {}", channel);
}
}
// Utility methods
/**
* Check if the channel admit any client identifier (so if the channel has a specific wildcard in the second topic level).<br>
* In the MQTT word this method return true if the topic starts with 'account/+/'.
*
* @param clientId
* @return
* @since 1.0.0
*/
private boolean isAnyClientId(String clientId) {
return DatastoreChannel.SINGLE_LEVEL_WCARD.equals(clientId);
}
/**
* This constructor should be used for wrapping Kapua message into datastore message for insert purpose
*
* @param message
*/
private DatastoreMessage convertTo(KapuaMessage<?, ?> message, String messageId) {
KapuaDataChannel datastoreChannel = new KapuaDataChannelImpl();
datastoreChannel.setSemanticParts(message.getChannel().getSemanticParts());
DatastoreMessage datastoreMessage = new DatastoreMessageImpl();
datastoreMessage.setCapturedOn(message.getCapturedOn());
datastoreMessage.setChannel(datastoreChannel);
datastoreMessage.setClientId(message.getClientId());
datastoreMessage.setDeviceId(message.getDeviceId());
datastoreMessage.setId(message.getId());
datastoreMessage.setPayload(message.getPayload());
datastoreMessage.setPosition(message.getPosition());
datastoreMessage.setReceivedOn(message.getReceivedOn());
datastoreMessage.setScopeId(message.getScopeId());
datastoreMessage.setSentOn(message.getSentOn());
// generate uuid
datastoreMessage.setId(message.getId());
datastoreMessage.setDatastoreId(STORABLE_ID_FACTORY.newStorableId(messageId));
return datastoreMessage;
}
public void refreshAllIndexes() throws ClientException {
getElasticsearchClient().refreshAllIndexes();
}
public void deleteAllIndexes() throws ClientException {
getElasticsearchClient().deleteAllIndexes();
}
public void deleteIndexes(String indexExp) throws ClientException {
getElasticsearchClient().deleteIndexes(indexExp);
}
}