use of com.google.monitoring.v3.Service in project java-servicedirectory by googleapis.
the class ServicesCreate method createService.
// Create a new service.
public static void createService(String projectId, String locationId, String namespaceId, String serviceId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
// The namespace to create the service in.
NamespaceName parent = NamespaceName.of(projectId, locationId, namespaceId);
// The service object to create.
// Optionally add some annotations for the service.
Service service = Service.newBuilder().putAnnotations("protocol", "tcp").build();
// Send the request to create the namespace.
Service createdService = client.createService(parent, service, serviceId);
// Process the response.
System.out.println("Created Service: " + createdService.getName());
System.out.println("Annotations: " + createdService.getAnnotations());
}
}
use of com.google.monitoring.v3.Service in project openstack4j by ContainX.
the class KeystoneToken method getAggregatedCatalog.
/**
* {@inheritDoc}
*/
@Override
@JsonIgnore
public SortedSetMultimap<String, Service> getAggregatedCatalog() {
if (aggregatedCatalog == null) {
synchronized (this) {
if (aggregatedCatalog == null) {
aggregatedCatalog = TreeMultimap.create();
for (Service sc : catalog) {
String nameKey = TYPE_WITHOUT_VERSION.apply(sc.getName());
String typeKey = TYPE_WITHOUT_VERSION.apply(sc.getType());
aggregatedCatalog.put(nameKey, sc);
aggregatedCatalog.put(typeKey, sc);
}
}
}
}
return aggregatedCatalog;
}
use of com.google.monitoring.v3.Service in project cloudbreak by hortonworks.
the class OpenStackClient method getRegion.
public Set<String> getRegion(CloudCredential cloudCredential) {
Access access = createAccess(cloudCredential);
Token token = createToken(cloudCredential);
Set<String> regions = new HashSet<>();
if (token == null && access == null) {
throw new CloudConnectorException("Unsupported keystone version");
} else if (token != null) {
for (Service service : token.getCatalog()) {
for (Endpoint endpoint : service.getEndpoints()) {
regions.add(endpoint.getRegion());
}
}
} else {
for (Access.Service service : access.getServiceCatalog()) {
for (org.openstack4j.model.identity.v2.Endpoint endpoint : service.getEndpoints()) {
regions.add(endpoint.getRegion());
}
}
}
LOGGER.info("regions from openstack: {}", regions);
return regions;
}
use of com.google.monitoring.v3.Service in project seldon-core by SeldonIO.
the class SeldonDeploymentOperatorImpl method createResources.
@Override
public DeploymentResources createResources(SeldonDeployment mlDep) throws SeldonDeploymentException {
OwnerReference ownerRef = getOwnerReference(mlDep);
List<Deployment> deployments = new ArrayList<>();
// for each predictor Create/replace deployment
String serviceLabel = mlDep.getSpec().getName();
for (PredictorSpec p : mlDep.getSpec().getPredictorsList()) {
String depName = getKubernetesDeploymentName(mlDep.getSpec().getName(), p.getName());
PodTemplateSpec.Builder podSpecBuilder = PodTemplateSpec.newBuilder(p.getComponentSpec());
podSpecBuilder.getSpecBuilder().addContainers(createEngineContainer(mlDep, p)).setTerminationGracePeriodSeconds(20);
podSpecBuilder.getMetadataBuilder().putAnnotations("prometheus.io/path", "/prometheus").putAnnotations("prometheus.io/port", "" + clusterManagerProperites.getEngineContainerPort()).putAnnotations("prometheus.io/scrape", "true");
Deployment deployment = V1beta1Extensions.Deployment.newBuilder().setMetadata(ObjectMeta.newBuilder().setName(depName).putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel).putLabels(Constants.LABEL_SELDON_ID, mlDep.getSpec().getName()).putLabels("app", depName).putLabels("version", // FIXME
"v1").putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_TYPE_KEY, SeldonDeploymentOperatorImpl.LABEL_SELDON_TYPE_VAL).addOwnerReferences(ownerRef)).setSpec(DeploymentSpec.newBuilder().setTemplate(podSpecBuilder.build()).setStrategy(DeploymentStrategy.newBuilder().setRollingUpdate(RollingUpdateDeployment.newBuilder().setMaxUnavailable(IntOrString.newBuilder().setType(1).setStrVal("10%")))).setReplicas(p.getReplicas())).build();
deployments.add(deployment);
}
final String serviceName = mlDep.getSpec().getName();
Service s = Service.newBuilder().setMetadata(ObjectMeta.newBuilder().setName(serviceName).putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel).putLabels("seldon-deployment-id", mlDep.getSpec().getName()).addOwnerReferences(ownerRef).putAnnotations("getambassador.io/config", getAmbassadorAnnotation(mlDep, serviceName))).setSpec(ServiceSpec.newBuilder().addPorts(ServicePort.newBuilder().setProtocol("TCP").setPort(clusterManagerProperites.getEngineContainerPort()).setTargetPort(IntOrString.newBuilder().setIntVal(clusterManagerProperites.getEngineContainerPort())).setName("http")).addPorts(ServicePort.newBuilder().setProtocol("TCP").setPort(clusterManagerProperites.getEngineGrpcContainerPort()).setTargetPort(IntOrString.newBuilder().setIntVal(clusterManagerProperites.getEngineGrpcContainerPort())).setName("grpc")).setType("ClusterIP").putSelector(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel)).build();
// Create service for deployment
return new DeploymentResources(deployments, s);
}
use of com.google.monitoring.v3.Service in project webtools.servertools by eclipse.
the class Tomcat40Configuration method modifyServerPort.
/**
* Modify the port with the given id.
*
* @param id java.lang.String
* @param port int
*/
public void modifyServerPort(String id, int port) {
try {
if ("server".equals(id)) {
server.setPort(port + "");
isServerDirty = true;
firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
return;
}
int i = id.indexOf("/");
// If a connector in the instance Service
if (i < 0) {
int connNum = Integer.parseInt(id);
Connector connector = serverInstance.getConnector(connNum);
if (connector != null) {
connector.setPort(port + "");
isServerDirty = true;
firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
}
} else // Else a connector in another Service
{
int servNum = Integer.parseInt(id.substring(0, i));
int connNum = Integer.parseInt(id.substring(i + 1));
Service service = server.getService(servNum);
Connector connector = service.getConnector(connNum);
connector.setPort(port + "");
isServerDirty = true;
firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
}
}
Aggregations