@Override public ClusterOperationRequest deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); Map<String, Object> providerFields = context.deserialize(jsonObj.get("providerFields"), new TypeToken<Map<String, Object>>() { }.getType()); return new ClusterOperationRequest(providerFields); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ClusterConfigureRequest that = (ClusterConfigureRequest) o; return super.equals(that) && Objects.equal(restart, that.restart) && Objects.equal(config, that.config); }
@Override public int hashCode() { return Objects.hashCode(super.hashCode(), name, description, clusterTemplate, numMachines, provider, services, hardwaretype, imagetype, initialLeaseDuration, dnsSuffix, config); }
String clusterId = cluster.getId(); Map<String, Object> providerFields = request == null ? Maps.<String, Object>newHashMap() : request.getProviderFields();
private void expireClusters(long currentTime) { try { LOG.debug("Expiring clusters older than {}", currentTime); Set<Cluster> clusters = clusterStore.getExpiringClusters(currentTime); if (clusters.isEmpty()) { LOG.debug("Got 0 clusters to be expired for time {}", currentTime); return; } LOG.debug("Got {} possible clusters to expire for time {}", clusters.size(), currentTime); for (Cluster cluster : clusters) { // mod check done here instead of db to avoid full table scan. if (Long.valueOf(cluster.getId()) % incrementBy == myMod) { LOG.debug("Deleting cluster {} with expire time {}", cluster.getId(), cluster.getExpireTime()); clusterService.requestClusterDelete(cluster.getId(), cluster.getAccount(), new ClusterOperationRequest(null)); } } } catch (Throwable e) { LOG.error("Got exception: ", e); } } }
@Override public int hashCode() { return Objects.hashCode(super.hashCode(), restart, config); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ClusterCreateRequest other = (ClusterCreateRequest) o; return super.equals(other) && Objects.equal(name, other.name) && Objects.equal(description, other.description) && Objects.equal(clusterTemplate, other.clusterTemplate) && Objects.equal(numMachines, other.numMachines) && Objects.equal(provider, other.provider) && Objects.equal(services, other.services) && Objects.equal(hardwaretype, other.hardwaretype) && Objects.equal(imagetype, other.imagetype) && Objects.equal(initialLeaseDuration, other.initialLeaseDuration) && Objects.equal(dnsSuffix, other.dnsSuffix) && Objects.equal(config, other.config); }
@Test public void testSensitiveUserFields() throws Exception { Map<String, Object> sensitiveFields = Maps.newHashMap(); sensitiveFields.put("key", "keycontents"); AddServicesRequest addRequest = new AddServicesRequest(sensitiveFields, ImmutableSet.of(service2.getName())); ClusterOperationRequest opRequest = new ClusterOperationRequest(sensitiveFields); Cluster cluster = createActiveCluster(); clusterService.requestAddServices(cluster.getId(), account, addRequest); testSensitiveFieldsAdded(cluster, sensitiveFields); clusterStore.deleteCluster(cluster.getId()); cluster = createActiveCluster(); clusterService.requestClusterDelete(cluster.getId(), account, opRequest); testSensitiveFieldsAdded(cluster, sensitiveFields); clusterStore.deleteCluster(cluster.getId()); cluster = createActiveCluster(); clusterService.requestServiceRuntimeAction(cluster.getId(), account, ClusterAction.RESTART_SERVICES, service1.getName(), opRequest); testSensitiveFieldsAdded(cluster, sensitiveFields); clusterStore.deleteCluster(cluster.getId()); }