Пример #1
0
 public void stopPersister(String collectionCode) {
   Client client = ClientBuilder.newBuilder().register(JacksonFeature.class).build();
   try {
     WebTarget webResource =
         client.target(
             Config.PERSISTER_REST_URI
                 + "collectionPersister/stop?collection_code="
                 + URLEncoder.encode(collectionCode, "UTF-8"));
     Response clientResponse = webResource.request(MediaType.APPLICATION_JSON).get();
     String jsonResponse = clientResponse.readEntity(String.class);
     logger.info(collectionCode + ": Collector persister response =  " + jsonResponse);
   } catch (RuntimeException e) {
     logger.error(collectionCode + ": Could not stop persister. Is persister running?");
     logger.error(elog.toStringException(e));
   } catch (UnsupportedEncodingException e) {
     // TODO Auto-generated catch block
     logger.error(collectionCode + ": Unsupported Encoding scheme used");
   }
 }
Пример #2
0
 @POST
 @Path("/endpoint/receive/{collection_code}")
 @Produces(MediaType.APPLICATION_JSON)
 @Consumes(MediaType.APPLICATION_JSON)
 public Response receive(@PathParam("collection_code") String code, SMS sms) {
   String smsCollections = GenericCache.getInstance().getSMSCollection(code.trim());
   if (Config.STATUS_CODE_COLLECTION_RUNNING.equals(smsCollections)) {
     try {
       ObjectMapper objectMapper = new ObjectMapper();
       String channelName = String.format(CHANNEL, code);
       if (redisLoadShedder.get(channelName).canProcess(channelName)) {
         JedisConnectionPool.getJedisConnection()
             .publish(channelName, objectMapper.writeValueAsString(sms));
       }
     } catch (Exception e) {
       logger.error("Exception in receiving from SMS collection: " + code + ", data: " + sms);
       logger.error(elog.toStringException(e));
     }
   }
   return Response.ok().build();
 }