/** * Get the client identifier (combining accountName and clientId).<br> * <b>If the id is null then it is generated</b> * * @param id * @param clientInfo * @return */ public static String getOrDeriveId(StorableId id, ClientInfo clientInfo) { return getOrDeriveId(id, clientInfo.getScopeId(), clientInfo.getClientId()); }
private Map<String, Object> marshalClientInfo(ClientInfo clientInfo) throws ParseException { Map<String, Object> unmarshalledClientInfo = new HashMap<>(); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_ID, clientInfo.getClientId()); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_MESSAGE_ID, clientInfo.getFirstMessageId().toString()); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_TIMESTAMP, KapuaDateUtils.formatDate(clientInfo.getFirstMessageOn())); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_SCOPE_ID, clientInfo.getScopeId().toStringId()); return unmarshalledClientInfo; }
private void checkClientInfoAgainstPreparedMessages(ClientInfoListResult cliInfo, List<KapuaDataMessage> msgLst) { Set<String> msgClients = new HashSet<>(); Set<String> infoClients = new HashSet<>(); assertNotNull("No client info data!", cliInfo); assertNotNull("No messages to compare to!", msgLst); for (KapuaDataMessage tmpMsg : msgLst) { msgClients.add(tmpMsg.getClientId()); } for (ClientInfo tmpClient : cliInfo.getItems()) { infoClients.add(tmpClient.getClientId()); } assertEquals("The number of clients does not match!", msgClients.size(), infoClients.size()); for (String tmpClient : msgClients) { assertTrue(String.format("The client id [%s] is not found in the info list!", tmpClient), infoClients.contains(tmpClient)); } }
@Then("^Client \"(.+)\" first message in the list \"(.+)\" is on \"(.+)\"$") public void checkFirstPublishDateForClient(String clientId, String lstKey, String date) throws Exception { ClientInfoListResult cliList = (ClientInfoListResult) stepData.get(lstKey); Date tmpCaptured = KapuaDateUtils.parseDate(date); for (ClientInfo tmpInfo : cliList.getItems()) { if (tmpInfo.getClientId().equals(clientId)) { assertEquals(tmpInfo.getFirstMessageOn(), tmpCaptured); return; } } fail(String.format("No client info item matches the client id [%s]", clientId)); }
@Then("^Client \"(.+)\" last message in the list \"(.+)\" is on \"(.+)\"$") public void checkLastPublishDateForClient(String clientId, String lstKey, String date) throws Exception { ClientInfoListResult cliList = (ClientInfoListResult) stepData.get(lstKey); Date tmpCaptured = KapuaDateUtils.parseDate(date); for (ClientInfo tmpInfo : cliList.getItems()) { if (tmpInfo.getClientId().equals(clientId)) { assertEquals(tmpInfo.getLastMessageOn(), tmpCaptured); return; } } fail(String.format("No client info item matches the client id [%s]", clientId)); }
TermPredicate clientIdPredicate = storablePredicateFactory.newTermPredicate(MessageField.CLIENT_ID, clientInfo.getClientId()); } else if (messageList.isEmpty()) { LOG.warn("Cannot find last timestamp for the specified client id '{}' - account '{}'", clientInfo.getScopeId(), clientInfo.getClientId()); } else { LOG.error("Cannot find last timestamp for the specified client id '{}' - account '{}'. More than one result returned by the query!", clientInfo.getScopeId(), clientInfo.getClientId());
if (!DatastoreCacheManager.getInstance().getClientsCache().get(clientInfo.getClientId())) { if (!DatastoreCacheManager.getInstance().getClientsCache().get(clientInfo.getClientId())) { DatastoreCacheManager.getInstance().getClientsCache().put(clientInfo.getClientId(), true);