Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
package com.tangosol.internal.management.resources;
import com.oracle.coherence.common.base.Logger;
import com.tangosol.internal.http.HttpException;
import com.tangosol.internal.http.HttpRequest;
import com.tangosol.internal.http.RequestRouter;
import com.tangosol.internal.http.Response;
import com.tangosol.internal.management.EntityMBeanResponse;
import com.tangosol.internal.management.MBeanResponse;
import com.tangosol.net.management.MBeanAccessor;
import com.tangosol.net.management.MBeanAccessor.QueryBuilder;
import com.tangosol.util.Filter;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.management.ObjectName;
/**
* Handles management API requests for services in a cluster.
*
* @author sr 2017.08.29
* @author Jonathan Knight 2022.01.25
* @since 12.2.1.4.0
*/
public class ServicesResource extends AbstractManagementResource
{
// ----- Routes methods -------------------------------------------------
@Override
public void addRoutes(RequestRouter router, String sPathRoot)
{
router.addGet(sPathRoot, this::get);
router.addGet(sPathRoot + "/" + MEMBERS, this::getAllServiceMembers);
router.addGet(sPathRoot + "/" + PROXY + "/" + MEMBERS, this::getAllProxyMembers);
router.addPost(sPathRoot + "/persistence/snapshots/{" + SNAPSHOT_NAME + "}", this::executeSnapshotOperationAllServices);
// child resources
router.addRoutes(sPathRoot + "/{" + SERVICE_NAME +"}", new ServiceResource());
}
// ----- GET API --------------------------------------------------------
/**
* Return the list of services in a cluster.
*
* @return the response object
*/
public Response get(HttpRequest request)
{
URI uriCurrent = getCurrentUri(request);
EntityMBeanResponse response = getResponseBodyForMBeanCollection(request, getQuery(request), new ServiceResource(),
NAME, null, getParentUri(request), uriCurrent, uriCurrent, null);
if (response == null && getService(request) != null)
{
return Response.status(Response.Status.NOT_FOUND).build();
}
return response == null
? response(new EntityMBeanResponse())
: response(response);
}
/**
* Returns the list of all ServiceMBean members in the cluster.
*
* @return the response object.
*/
public Response getAllServiceMembers(HttpRequest request)
{
return response(getResponseBodyForMBeanCollection(request, getQuery(request), null,
getParentUri(request), getCurrentUri(request)));
}
/**
* Returns the list of all ServiceMBean members in the cluster.
*
* @return the response object.
*/
public Response getAllProxyMembers(HttpRequest request)
{
QueryBuilder queryBuilder = createQueryBuilder(request).withBaseQuery(CONNECTION_MANAGERS_QUERY);
return response(getResponseBodyForMBeanCollection(request, queryBuilder, null,
getParentUri(request), getCurrentUri(request)));
}
/**
* Issues a "createSnapshot" operation on the PersistenceManagerMBean for
* all persistence enabled services.
*
* Note: the implementation does not (currently) perform a "safe" snapshot
* across all services (i.e. all or nothing).
*
* @return the response object
*/
public Response executeSnapshotOperationAllServices(HttpRequest request)
{
String sSnapshotName = request.getFirstPathParameter(SNAPSHOT_NAME);
String[] asSignature = {String.class.getName()};
Object[] aoArguments = {sSnapshotName};
// get the list of services enabled for persistence
EntityMBeanResponse response = getResponseBodyForMBeanCollection(request, instantiatePersistentServicesQuery(request), null,
getParentUri(request), getCurrentUri(request));
List