Search in sources :

Example 56 with MultivaluedMapImpl

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;
}
Also used : MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) VNXUnityTreeQuota(com.emc.storageos.vnxe.models.VNXUnityTreeQuota)

Example 57 with MultivaluedMapImpl

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);
}
Also used : MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) VNXUnityTreeQuota(com.emc.storageos.vnxe.models.VNXUnityTreeQuota)

Example 58 with MultivaluedMapImpl

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"));
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Matchers.anyString(org.mockito.Matchers.anyString) StepMeta(org.pentaho.di.trans.step.StepMeta) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) Trans(org.pentaho.di.trans.Trans) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 59 with MultivaluedMapImpl

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();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) JSONObject(org.codehaus.jettison.json.JSONObject) MockNM(org.apache.hadoop.yarn.server.resourcemanager.MockNM) MockAM(org.apache.hadoop.yarn.server.resourcemanager.MockAM) WebResource(com.sun.jersey.api.client.WebResource) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.junit.Test)

Example 60 with MultivaluedMapImpl

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();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) JSONObject(org.codehaus.jettison.json.JSONObject) MockNM(org.apache.hadoop.yarn.server.resourcemanager.MockNM) WebResource(com.sun.jersey.api.client.WebResource) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.junit.Test)

Aggregations

MultivaluedMapImpl (com.sun.jersey.core.util.MultivaluedMapImpl)131 Test (org.junit.Test)55 ClientResponse (com.sun.jersey.api.client.ClientResponse)48 WebResource (com.sun.jersey.api.client.WebResource)39 JSONObject (org.codehaus.jettison.json.JSONObject)39 Test (org.testng.annotations.Test)35 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)13 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)12 List (java.util.List)11 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)11 JSONArray (org.codehaus.jettison.json.JSONArray)9 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)8 Client (com.sun.jersey.api.client.Client)7 SearchFilter (org.apache.atlas.model.SearchFilter)7 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)7 WebDriverHelper (org.orcid.api.common.WebDriverHelper)7 Response (javax.ws.rs.core.Response)6 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)6 AtlasLineageInfo (org.apache.atlas.model.lineage.AtlasLineageInfo)6 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)6