use of com.sun.jersey.core.util.MultivaluedMapImpl in project coprhd-controller by CoprHD.
the class FileSystemQuotaRequests method getByName.
/**
* Get quota details by it's name
*
* @param fsId
* id of associated fs
* @param quotaName
* name of the quota
* @return VNXUnityTreeQuota - the quota object
*/
public VNXUnityTreeQuota getByName(String fsId, String quotaName) {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(VNXeConstants.FILTER, VNXeConstants.PATH_FILTER + "\"" + "/" + quotaName + "\"" + " and " + VNXeConstants.FILE_SYSTEM_FILTER_V31 + "\"" + fsId + "\"");
setQueryParameters(queryParams);
VNXUnityTreeQuota result = null;
_url = URL;
List<VNXUnityTreeQuota> quotaList = getDataForObjects(VNXUnityTreeQuota.class);
// it should just return 1
if (quotaList != null && !quotaList.isEmpty()) {
result = quotaList.get(0);
_logger.info("file system tree quota found using the name: " + quotaName);
} else {
_logger.info("No file system tree quota found using the name: " + quotaName);
}
return result;
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project coprhd-controller by CoprHD.
the class FileSystemQuotaRequests method updateFileSystemQuotaSync.
/**
* update file system quota in sync mode
*
* @param quotaId
* Id of the quota
* @param param
* FileSystemQuotaModifyParam
* @return VNXeCommandResult
* @throws VNXeException
*/
public VNXeCommandResult updateFileSystemQuotaSync(String quotaId, FileSystemQuotaModifyParam param) throws VNXeException {
_logger.info("Sync update quota with ID: " + quotaId);
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(VNXeConstants.TIMEOUT, "0");
setQueryParameters(queryParams);
VNXUnityTreeQuota quota = getFileSystemQuota(quotaId);
_url = URL_INSTANCE + quota.getId() + URL_MODIFY;
return postRequestSync(param);
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project pentaho-kettle by pentaho.
the class RestTest method testCreateMultivalueMap.
@Test
public void testCreateMultivalueMap() {
StepMeta stepMeta = new StepMeta();
stepMeta.setName("TestRest");
TransMeta transMeta = new TransMeta();
transMeta.setName("TestRest");
transMeta.addStep(stepMeta);
Rest rest = new Rest(stepMeta, mock(StepDataInterface.class), 1, transMeta, mock(Trans.class));
MultivaluedMapImpl map = rest.createMultivalueMap("param1", "{a:{[val1]}}");
String val1 = map.getFirst("param1");
assertTrue(val1.contains("%7D"));
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.
the class TestRMWebServicesSchedulerActivities method testWrongNodeId.
@Test
public void testWrongNodeId() throws Exception {
//Start RM so that it accepts app submissions
rm.start();
MockNM nm = new MockNM("127.0.0.1:1234", 24 * 1024, rm.getResourceTrackerService());
nm.registerNode();
try {
RMApp app1 = rm.submitApp(1024, "app1", "user1", null, "b1");
MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm);
am1.allocate(Arrays.asList(ResourceRequest.newInstance(Priority.UNDEFINED, "127.0.0.1", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "/default-rack", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "*", Resources.createResource(1024), 10)), null);
//Get JSON
WebResource r = resource();
MultivaluedMapImpl params = new MultivaluedMapImpl();
params.add("nodeId", "127.0.0.0");
ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
nm.nodeHeartbeat(true);
Thread.sleep(1000);
//Get JSON
response = r.path("ws").path("v1").path("cluster").path("scheduler/activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
json = response.getEntity(JSONObject.class);
verifyNumberOfAllocations(json, 0);
} finally {
rm.stop();
}
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.
the class TestRMWebServicesSchedulerActivities method testAppActivityJSON.
@Test
public void testAppActivityJSON() throws Exception {
//Start RM so that it accepts app submissions
rm.start();
MockNM nm = new MockNM("127.0.0.1:1234", 24 * 1024, rm.getResourceTrackerService());
nm.registerNode();
try {
RMApp app1 = rm.submitApp(10, "app1", "user1", null, "b1");
//Get JSON
WebResource r = resource();
MultivaluedMapImpl params = new MultivaluedMapImpl();
params.add("appId", app1.getApplicationId().toString());
ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/app-activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
nm.nodeHeartbeat(true);
Thread.sleep(5000);
//Get JSON
response = r.path("ws").path("v1").path("cluster").path("scheduler/app-activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
json = response.getEntity(JSONObject.class);
verifyNumberOfAllocations(json, 1);
JSONObject allocations = json.getJSONObject("allocations");
verifyStateOfAllocations(allocations, "allocationState", "ACCEPTED");
verifyNumberOfAllocationAttempts(allocations, 1);
} finally {
rm.stop();
}
}
Aggregations