@Override public void execute(Tuple input, BasicOutputCollector collector) { try { BitlyInfos bInfos = (BitlyInfos) input.getValueByField("bitlyInfos"); DataInsertion data = new DataInsertion(); data.addBitlyInfos(bInfos, keyspace); } catch (HectorException e) { e.printStackTrace(); } }
@SuppressWarnings("unchecked") public void setAmountChunksWithContent(String owner_name, String fileName, long amountChunks) { try { Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, stringSerializer); mutator.insert( owner_name, "UserFiles", HFactory.createSuperColumn( fileName, Arrays.asList( HFactory.createStringColumn("chunks_with_content", String.valueOf(amountChunks))), stringSerializer, stringSerializer, stringSerializer)); } catch (HectorException e) { log.error("Data was not inserted"); e.printStackTrace(); } }
/** Inserts a new row on the UserFiles SuperColumn Family */ @SuppressWarnings("unchecked") public void insertRow( String owner_name, String fileName, String fileID, String size, String chunks, String version, int defaultChunkSize) { try { Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, stringSerializer); mutator.insert( owner_name, "UserFiles", HFactory.createSuperColumn( fileName, Arrays.asList(HFactory.createStringColumn("file_id", fileID)), stringSerializer, stringSerializer, stringSerializer)); mutator.insert( owner_name, "UserFiles", HFactory.createSuperColumn( fileName, Arrays.asList(HFactory.createStringColumn("size", size)), stringSerializer, stringSerializer, stringSerializer)); mutator.insert( owner_name, "UserFiles", HFactory.createSuperColumn( fileName, Arrays.asList(HFactory.createStringColumn("chunks", chunks)), stringSerializer, stringSerializer, stringSerializer)); mutator.insert( owner_name, "UserFiles", HFactory.createSuperColumn( fileName, Arrays.asList(HFactory.createStringColumn("version", version)), stringSerializer, stringSerializer, stringSerializer)); mutator.insert( owner_name, "UserFiles", HFactory.createSuperColumn( fileName, Arrays.asList( HFactory.createStringColumn( "default_chunk_size", String.valueOf(defaultChunkSize))), stringSerializer, stringSerializer, stringSerializer)); } catch (HectorException e) { log.error("Data was not inserted"); e.printStackTrace(); } }
public void handlRequest(HttpServletRequest request, HttpServletResponse response) { printRequest(request); String method = request.getParameter(ServiceConstant.METHOD); CommonService obj = null; try { obj = CommonService.createServiceObjectByMethod(method); } catch (InstantiationException e1) { log.severe( "<handlRequest> but exception while create service object for method(" + method + "), exception=" + e1.toString()); e1.printStackTrace(); } catch (IllegalAccessException e1) { log.severe( "<handlRequest> but exception while create service object for method(" + method + "), exception=" + e1.toString()); e1.printStackTrace(); } try { if (obj == null) { sendResponseByErrorCode(response, ErrorCode.ERROR_PARA_METHOD_NOT_FOUND); return; } obj.setCassandraClient(cassandraClient); obj.setMongoClient(mongoClient); obj.setRequest(request); if (!obj.validateSecurity(request)) { sendResponseByErrorCode(response, ErrorCode.ERROR_INVALID_SECURITY); return; } // parse request parameters if (!obj.setDataFromRequest(request)) { sendResponseByErrorCode(response, obj.resultCode); return; } // print parameters obj.printData(); // handle request obj.handleData(); } catch (HectorException e) { obj.resultCode = ErrorCode.ERROR_CASSANDRA; log.severe("catch DB exception=" + e.toString()); e.printStackTrace(); } catch (JSONException e) { obj.resultCode = ErrorCode.ERROR_JSON; log.severe("catch JSON exception=" + e.toString()); e.printStackTrace(); } catch (Exception e) { obj.resultCode = ErrorCode.ERROR_SYSTEM; log.severe("catch general exception=" + e.toString()); e.printStackTrace(); } finally { } String responseData = obj.getResponseString(); // send back response sendResponse(response, responseData); }