3
우리는 특정 지역의 전체 데이터를 삭제할 수 있지만, 그렇다면 어떻게 gemfire에서 하나의 특정 키와 그 값을 삭제할 수 있습니까? 그리고 그 다음에도 없다면?java를 사용하여 gemfire에서 특정 데이터 (키 및 해당 값)를 삭제할 수 있습니까?
GeodeConfiguration 클래스
@Configuration 공용 클래스 GeodeConfiguration {
@SuppressWarnings("rawtypes")
@Bean
Region gemfireRegion() throws InterruptedException {
ClientCache cache = new ClientCacheFactory()
.setPdxSerializer(
new ReflectionBasedAutoSerializer(PropertiesCache
.getInstance()
.getProperty("pdxSerializerValue")))
.addPoolLocator(
PropertiesCache.getInstance().getProperty("hostname"),
10334).create();
Region<String, String> region = cache
.<String, String> createClientRegionFactory(
ClientRegionShortcut.CACHING_PROXY)
.setEntryTimeToLive(new ExpirationAttributes(50))
.create(PropertiesCache.getInstance().getProperty("region"));
return region;
}
}
Mobilecontroller 클래스
@Controller 술집 LIC 클래스 MobileController {
@Autowired
Operations operations;
Msg msg = new Msg();
final static Logger logger = Logger.getLogger(MobileController.class);
@RequestMapping(value = "/mobile", method = RequestMethod.POST)
public void dataFromEs(@RequestParam("name") String name,
@RequestParam("message") String message,
@RequestParam("mobileNo") String[] mobileNo) throws IOException,
JSONException {
JSONObject obj = new JSONObject();
obj.put("userName", name);
obj.put("message", message);
JSONObject mainObj = new JSONObject();
JSONArray jsonArray = new JSONArray();
for (int counter = 0; counter < mobileNo.length; counter++) {
// 1st object
JSONObject list1 = new JSONObject();
list1.put("mobilenumber", mobileNo[counter]);
jsonArray.put(list1);
}
mainObj.put("data", obj);
obj.put("mobileno", jsonArray);
logger.info("jsonString----------->: " + jsonArray);
logger.info(mainObj);
msg.setKey(name);
msg.setValue(mainObj.toString());
operations.saveMessageData(msg);
sendMSG(name);
}
public void sendMSG(String name) throws ClientProtocolException,
IOException, JSONException {
String objMobileNo;
String objMessage;
String objUserName;
String userStatus;
JSONObject root = new JSONObject(operations.getDataValue(name));
JSONObject jsonObject = root.getJSONObject("data");
objUserName = (String) jsonObject.get("userName");
objMessage = (String) jsonObject.get("message");
logger.info("UserName ----> " + objUserName);
logger.info("Message sent ---> " + objMessage);
JSONArray mobArray = jsonObject.getJSONArray("mobileno");
// now get the first element:
for (int count = 0; count < mobArray.length(); count++) {
objMobileNo = (String) mobArray.getJSONObject(count).get(
"mobilenumber");
logger.info("Mobile number ----> " + objMobileNo);
JSONObject obj = new JSONObject();
JSONObject objDraftOne = new JSONObject();
JSONObject objDraftTwo = new JSONObject();
JSONObject jsonObjectToSave = new JSONObject();
JSONObject jsonObjectToSaveDraft = new JSONObject();
JSONArray jsonArray = new JSONArray();
objDraftTwo.put("mobilenumber", objMobileNo);
jsonArray.put(objDraftTwo);
objDraftOne.put("mobileno", jsonArray);
objDraftOne.put("userName", objUserName);
objDraftOne.put("message", objMessage);
jsonObjectToSaveDraft.put("data", objDraftOne);
obj.put("userName", objUserName);
obj.put("message", objMessage);
obj.put("mobilenumber", objMobileNo);
jsonObjectToSave.put("data", obj);
HttpClient client = HttpClientBuilder.create().build();
HttpPost request = new HttpPost(
"https://xyzotp.bdt.xyz.com/sendSMS");
StringEntity params = new StringEntity(jsonObjectToSave.toString());
request.addHeader("content-type", "application/json");
request.setEntity(params);
HttpResponse response = client.execute(request);
String responseAsString = EntityUtils
.toString(response.getEntity());
JSONObject responseObjectStatus = new JSONObject(responseAsString);
userStatus = (String) responseObjectStatus.get("message");
logger.info("Message Status: " + userStatus);
if (!userStatus.equals("Message sent successfully")) {
logger.info(jsonObjectToSaveDraft);
}
}
}
} 위의 코드에서
는 이름는 모든 시간을 변경하려고하는 키이고 우리는
를 전달 키와 값을 제거하려면