public static boolean validate(Operation op, ValidateOperationHandler validateHandler) { try { validateHandler.validate(); return true; } catch (Exception e) { handleValidationException(op, e); return false; } }
private void subscribeForSslTrustCertNotifications() { this.subscriptionManager.start((n) -> { loadSslTrustCertServices(); }, null); }
public SubscriptionManager(ServiceHost host, String uniqueSubscriptionId, String subscribeForServiceLink, Class<T> type, boolean useSubscriptionPollingStrategy) { AssertUtil.assertNotNull(host, "serviceHost"); AssertUtil.assertNotEmpty(subscribeForServiceLink, "subscribeForServiceLink"); AssertUtil.assertNotNull(type, "type"); AssertUtil.assertNotNull(uniqueSubscriptionId, "uniqueSubscriptionId"); this.host = host; this.type = type; this.uniqueSubscriptionId = uniqueSubscriptionId; this.subscribeForServiceLink = subscribeForServiceLink; this.subscribeForNotifications = useSubscriptionPollingStrategy ? !SUBSCRIPTION_POLLING_STRATEGY : true; this.documentQuery = new ServiceDocumentQuery<T>(host, type); }
@Override protected void validateStateOnStart(PKSClusterRemovalTaskState task) throws IllegalArgumentException { AssertUtil.assertNotNull(task, "task"); AssertUtil.assertNotEmpty(task.resourceLink, "resourceLink"); }
private QueryTask createResourcesQuery(Class<? extends ServiceDocument> type, Collection<String> resourceLinks) { QueryTask query = QueryUtil.buildQuery(type, false); QueryUtil.addListValueClause(query, ServiceDocument.FIELD_NAME_SELF_LINK, resourceLinks); return query; }
static String apiPrefix(KubernetesContext context, String apiVersion) { AssertUtil.assertNotNull(context.host, "context.host"); AssertUtil.assertNotNullOrEmpty(context.host.address, "context.host.address"); return context.host.address + apiVersion; }
public PrincipalRolesHandler setService(Service service) { assertNotNull(service, "service"); this.service = service; return this; }
protected void merge(CounterSubTaskState patchBody) { this.customProperties = mergeCustomProperties(this.customProperties, patchBody.customProperties); } }
/** * Subscribe for the specified service link and provide a notification handler to be callback * when there is an update or delete of the specified services. * The Consumer<String> callback will contain either the subscription ID or null in case * something went wrong. */ public void start(Consumer<SubscriptionNotification<T>> notificationHandler, Consumer<String> callback) { start(notificationHandler, false, callback); }
/** * Perform shallow merge of ServiceDocuments using reflection * * @param copyTo * @param copyFrom */ public static void mergeServiceDocuments(ServiceDocument copyTo, ServiceDocument copyFrom) { mergeServiceDocuments(copyTo, copyFrom, SHALLOW_MERGE_STRATEGY); }
/** * Create a query to return all RegistryState links within a group, tenant or global * RegistryState links if the tenantLinks collection is null/empty. * * @param tenantLinks * @return QueryTask */ private static Query buildQueryByTenantLinks(Collection<String> tenantLinks) { return QueryUtil.addTenantGroupAndUserClause(tenantLinks); }
protected RemoteApiDockerAdapterCommandExecutorImpl(ServiceHost host, TrustManager trustManager) { this.host = host; this.serviceClient = ServiceClientFactory.createServiceClient(trustManager, keyManager); this.attachServiceClient = ServiceClientFactory.createServiceClient(trustManager, keyManager); this.largeDataClient = ServiceClientFactory.createServiceClient( trustManager, keyManager, DOCKER_REQUEST_PAYLOAD_SIZE_LIMIT); if (trustManager instanceof ServerX509TrustManager) { this.trustManager = (ServerX509TrustManager) trustManager; } }
/** * Create a query to return all RegistryState links within a group, tenant or global * RegistryState links if the tenantLinks collection is null/empty. * * @param tenantLinks * @return QueryTask */ private static QueryTask buildRegistryQueryByTenantLinks(Collection<String> tenantLinks) { return buildRegistryQuery(buildQueryByTenantLinks(tenantLinks)); }
@Override public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { delegatingTrustManager.checkClientTrusted(chain, authType); }
/** * TODO Currently all authorized non-guest users are devOpsAdmins. Needs to be changed after * roles are introduced. */ public static boolean isDevOpsAdmin(Operation op) { return !OperationUtil.isGuestUser(op); }
/** * Close the resources and unsubscribe. */ @Override public void close() { unsubscribe(); }
public static DockerImage fromParts(String hostPart, String namespacePart, String repo, String tag) { DockerImage dockerImage = new DockerImage(); dockerImage.host = hostPart; dockerImage.namespace = namespacePart; dockerImage.repository = repo; dockerImage.tag = tag; return dockerImage; }
/** * Converts a memory binary value from one unit to another. * * @param magnitude the magnitude * @param inUnit the input (comparison is case insensitve) * @param outUnit the output (comparison is case insensitve) * @return the value converted to bytes */ public static double memoryBinaryConversion(double inMagnitude, String inUnit, String outUnit) { return memoryConversion(inMagnitude, inUnit, outUnit, false); }
private void validateStateOnStart(EventLogState state) { assertNotNull(state.description, "description"); assertNotNull(state.resourceType, "resourceType"); assertNotNull(state.eventLogType, "eventLogType"); } }
public PrincipalRolesHandler setRoleAssignment(PrincipalRoleAssignment roleAssignment) { assertNotNull(roleAssignment, "roleAssignment"); this.roleAssignment = roleAssignment; return this; }