Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3C7E320049D for ; Wed, 9 Aug 2017 17:55:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3B186169742; Wed, 9 Aug 2017 15:55:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 03750169722 for ; Wed, 9 Aug 2017 17:55:19 +0200 (CEST) Received: (qmail 49482 invoked by uid 500); 9 Aug 2017 15:55:16 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 49004 invoked by uid 99); 9 Aug 2017 15:55:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Aug 2017 15:55:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 97C3FF556B; Wed, 9 Aug 2017 15:55:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jluniya@apache.org To: commits@ambari.apache.org Date: Wed, 09 Aug 2017 15:55:46 -0000 Message-Id: <4976a735a0474947ad7778fce228b776@git.apache.org> In-Reply-To: <1bd593aa6951467e925c8996f5b2760e@git.apache.org> References: <1bd593aa6951467e925c8996f5b2760e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [33/52] [abbrv] ambari git commit: AMBARI-21659. Remove obsolete security_state data (amagyar) archived-at: Wed, 09 Aug 2017 15:55:22 -0000 AMBARI-21659. Remove obsolete security_state data (amagyar) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2258b106 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2258b106 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2258b106 Branch: refs/heads/branch-feature-AMBARI-14714 Commit: 2258b10639d510f879953b41dc4709b9e12ed05a Parents: e89e950 Author: Attila Magyar Authored: Fri Aug 4 16:09:32 2017 +0200 Committer: Attila Magyar Committed: Fri Aug 4 16:09:32 2017 +0200 ---------------------------------------------------------------------- .../checks/DatabaseConsistencyCheckHelper.java | 2 - .../server/controller/KerberosHelperImpl.java | 160 +------------------ .../HostComponentDesiredStateEntity.java | 14 -- .../orm/entities/HostComponentStateEntity.java | 13 -- .../orm/entities/ServiceDesiredStateEntity.java | 13 -- .../kerberos/FinalizeKerberosServerAction.java | 39 ----- .../PrepareDisableKerberosServerAction.java | 8 +- .../ambari/server/state/SecurityState.java | 83 ---------- .../org/apache/ambari/server/state/Service.java | 18 --- .../server/state/ServiceComponentHost.java | 39 ----- .../apache/ambari/server/state/ServiceImpl.java | 21 --- .../svccomphost/ServiceComponentHostImpl.java | 60 ------- .../server/upgrade/UpgradeCatalog300.java | 11 ++ .../main/resources/Ambari-DDL-Derby-CREATE.sql | 3 - .../main/resources/Ambari-DDL-MySQL-CREATE.sql | 3 - .../main/resources/Ambari-DDL-Oracle-CREATE.sql | 3 - .../resources/Ambari-DDL-Postgres-CREATE.sql | 3 - .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 3 - .../resources/Ambari-DDL-SQLServer-CREATE.sql | 3 - .../server/agent/HeartbeatProcessorTest.java | 5 - .../server/agent/TestHeartbeatHandler.java | 9 +- .../server/controller/KerberosHelperTest.java | 51 ------ .../FinalizeKerberosServerActionTest.java | 6 - .../apache/ambari/server/state/ServiceTest.java | 41 ----- .../svccomphost/ServiceComponentHostTest.java | 52 ------ .../server/upgrade/UpgradeCatalog300Test.java | 8 + 26 files changed, 25 insertions(+), 646 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java index 2559339..b440c93 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java @@ -60,7 +60,6 @@ import org.apache.ambari.server.orm.entities.MetainfoEntity; import org.apache.ambari.server.orm.entities.ServiceComponentDesiredStateEntity; import org.apache.ambari.server.state.ClientConfigFileDefinition; import org.apache.ambari.server.state.ComponentInfo; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.ServiceInfo; import org.apache.ambari.server.state.State; import org.apache.ambari.server.state.UpgradeState; @@ -723,7 +722,6 @@ public class DatabaseConsistencyCheckHelper { stateEntity.setHostEntity(hostComponentDesiredStateEntity.getHostEntity()); stateEntity.setCurrentState(State.UNKNOWN); stateEntity.setUpgradeState(UpgradeState.NONE); - stateEntity.setSecurityState(SecurityState.UNKNOWN); stateEntity.setServiceComponentDesiredStateEntity(hostComponentDesiredStateEntity.getServiceComponentDesiredStateEntity()); LOG.error("Trying to add missing record in hostcomponentstate: {}", stateEntity); http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java index 6b50ea4..7b8f58d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java @@ -96,7 +96,6 @@ import org.apache.ambari.server.state.Config; import org.apache.ambari.server.state.ConfigHelper; import org.apache.ambari.server.state.Host; import org.apache.ambari.server.state.HostState; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.SecurityType; import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceComponent; @@ -1700,7 +1699,6 @@ public class KerberosHelperImpl implements KerberosHelper { throws AmbariException, KerberosOperationException { final KerberosDescriptor kerberosDescriptor = getKerberosDescriptor(cluster); - final SecurityState desiredSecurityState = handler.getNewServiceSecurityState(); List schToProcess = getServiceComponentHostsToProcess( cluster, @@ -1708,12 +1706,7 @@ public class KerberosHelperImpl implements KerberosHelper { serviceComponentFilter, hostFilter, identityFilter, - new Command() { - @Override - public Boolean invoke(ServiceComponentHost arg) throws AmbariException { - return handler.shouldProcess(desiredSecurityState, arg); - } - }); + arg -> true); // While iterating over all the ServiceComponentHosts find hosts that have KERBEROS_CLIENT @@ -1782,34 +1775,6 @@ public class KerberosHelperImpl implements KerberosHelper { handler.addFinalizeOperationStage(cluster, clusterHostInfoJson, hostParamsJson, event, dataDirectory, roleCommandOrder, requestStageContainer, kerberosDetails); - // If all goes well, set the appropriate states on the relevant ServiceComponentHosts - for (ServiceComponentHost sch : schToProcess) { - // Update the desired and current states for the ServiceComponentHost - // using new state information from the the handler implementation - SecurityState newSecurityState; - - newSecurityState = handler.getNewDesiredSCHSecurityState(); - if (newSecurityState != null) { - sch.setDesiredSecurityState(newSecurityState); - } - - newSecurityState = handler.getNewSCHSecurityState(); - if (newSecurityState != null) { - sch.setSecurityState(newSecurityState); - } - } - - // If all goes well, set all services to _desire_ to be secured or unsecured, depending on handler - if (desiredSecurityState != null) { - Map services = cluster.getServices(); - - for (Service service : services.values()) { - if ((serviceComponentFilter == null) || serviceComponentFilter.containsKey(service.getName())) { - service.setSecurityState(desiredSecurityState); - } - } - } - return requestStageContainer; } @@ -2755,42 +2720,7 @@ public class KerberosHelperImpl implements KerberosHelper { * "right" thing for the task at hand. */ private abstract class Handler { - /** - * Tests the Service and ServiceComponentHost to see if they are in the appropriate security - * state to be processed for the relevant task. - * - * @param desiredSecurityState the SecurityState to be transitioned to - * @param sch the ServiceComponentHost to test - * @return true if both the Service and ServiceComponentHost are in the appropriate security - * state to be processed; otherwise false - * @throws AmbariException of an error occurs while testing - */ - abstract boolean shouldProcess(SecurityState desiredSecurityState, ServiceComponentHost sch) throws AmbariException; - /** - * Returns the new SecurityState to be set as the ServiceComponentHost's _desired_ SecurityState. - * - * @return a SecurityState to be set as the ServiceComponentHost's _desired_ SecurityState; - * or null if no state change is desired - */ - abstract SecurityState getNewDesiredSCHSecurityState(); - - /** - * Returns the new SecurityState to be set as the ServiceComponentHost's _current_ SecurityState. - * - * @return a SecurityState to be set as the ServiceComponentHost's _current_ SecurityState; - * or null if no state change is desired - */ - abstract SecurityState getNewSCHSecurityState(); - - - /** - * Returns the new SecurityState to be set as the Service's SecurityState. - * - * @return a SecurityState to be set as the Service's SecurityState; - * or null if no state change is desired - */ - abstract SecurityState getNewServiceSecurityState(); /** * Creates the necessary stages to complete the relevant task and stores them in the supplied @@ -3308,10 +3238,6 @@ public class KerberosHelperImpl implements KerberosHelper { * EnableKerberosHandler is an implementation of the Handler interface used to enable Kerberos * on the relevant cluster *

- * This implementation attempts to set the Service and ServiceComponentHost _desired_ security - * states to {@link org.apache.ambari.server.state.SecurityState#SECURED_KERBEROS} and the - * ServiceComponentHost _current_ security state to {@link org.apache.ambari.server.state.SecurityState#SECURING}. - *

* To complete the process, this implementation creates the following stages: *

    *
  1. create principals
  2. @@ -3321,25 +3247,6 @@ public class KerberosHelperImpl implements KerberosHelper { *
*/ private class EnableKerberosHandler extends Handler { - @Override - public boolean shouldProcess(SecurityState desiredSecurityState, ServiceComponentHost sch) throws AmbariException { - return (desiredSecurityState == SecurityState.SECURED_KERBEROS); - } - - @Override - public SecurityState getNewDesiredSCHSecurityState() { - return SecurityState.SECURED_KERBEROS; - } - - @Override - public SecurityState getNewSCHSecurityState() { - return SecurityState.SECURING; - } - - @Override - public SecurityState getNewServiceSecurityState() { - return SecurityState.SECURED_KERBEROS; - } @Override public long createStages(Cluster cluster, @@ -3431,10 +3338,6 @@ public class KerberosHelperImpl implements KerberosHelper { * DisableKerberosHandler is an implementation of the Handler interface used to disable Kerberos * on the relevant cluster *

- * This implementation attempts to set the Service and ServiceComponentHost _desired_ security - * states to {@link org.apache.ambari.server.state.SecurityState#UNSECURED} and the ServiceComponentHost - * _current_ security state to {@link org.apache.ambari.server.state.SecurityState#UNSECURING}. - *

* To complete the process, this implementation creates the following stages: *

    *
  1. update relevant configurations
  2. @@ -3444,27 +3347,6 @@ public class KerberosHelperImpl implements KerberosHelper { *
*/ private class DisableKerberosHandler extends Handler { - @Override - public boolean shouldProcess(SecurityState desiredSecurityState, ServiceComponentHost sch) throws AmbariException { - return (desiredSecurityState == SecurityState.UNSECURED) && - ((sch.getDesiredSecurityState() != SecurityState.UNSECURED) || (sch.getSecurityState() != SecurityState.UNSECURED)) && - (sch.getSecurityState() != SecurityState.UNSECURING); - } - - @Override - public SecurityState getNewDesiredSCHSecurityState() { - return SecurityState.UNSECURED; - } - - @Override - public SecurityState getNewSCHSecurityState() { - return SecurityState.UNSECURING; - } - - @Override - public SecurityState getNewServiceSecurityState() { - return SecurityState.UNSECURED; - } @Override public long createStages(Cluster cluster, @@ -3593,26 +3475,6 @@ public class KerberosHelperImpl implements KerberosHelper { } @Override - public boolean shouldProcess(SecurityState desiredSecurityState, ServiceComponentHost sch) throws AmbariException { - return true; - } - - @Override - public SecurityState getNewDesiredSCHSecurityState() { - return null; - } - - @Override - public SecurityState getNewSCHSecurityState() { - return null; - } - - @Override - public SecurityState getNewServiceSecurityState() { - return null; - } - - @Override public long createStages(Cluster cluster, String clusterHostInfoJson, String hostParamsJson, ServiceComponentHostServerActionEvent event, @@ -3723,26 +3585,6 @@ public class KerberosHelperImpl implements KerberosHelper { private class DeletePrincipalsAndKeytabsHandler extends Handler { @Override - public boolean shouldProcess(SecurityState desiredSecurityState, ServiceComponentHost sch) throws AmbariException { - return true; - } - - @Override - public SecurityState getNewDesiredSCHSecurityState() { - return null; - } - - @Override - public SecurityState getNewSCHSecurityState() { - return null; - } - - @Override - public SecurityState getNewServiceSecurityState() { - return null; - } - - @Override public long createStages(Cluster cluster, String clusterHostInfoJson, String hostParamsJson, ServiceComponentHostServerActionEvent event, http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java index 05ae532..36a7a25 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java @@ -38,7 +38,6 @@ import javax.persistence.UniqueConstraint; import org.apache.ambari.server.state.HostComponentAdminState; import org.apache.ambari.server.state.MaintenanceState; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.State; import com.google.common.base.Objects; @@ -94,11 +93,6 @@ public class HostComponentDesiredStateEntity { @Enumerated(value = EnumType.STRING) private State desiredState = State.INIT; - @Basic - @Column(name = "security_state", nullable = false, insertable = true, updatable = true) - @Enumerated(value = EnumType.STRING) - private SecurityState securityState = SecurityState.UNSECURED; - @Enumerated(value = EnumType.STRING) @Column(name = "admin_state", nullable = true, insertable = true, updatable = true) private HostComponentAdminState adminState; @@ -160,14 +154,6 @@ public class HostComponentDesiredStateEntity { this.desiredState = desiredState; } - public SecurityState getSecurityState() { - return securityState; - } - - public void setSecurityState(SecurityState securityState) { - this.securityState = securityState; - } - public HostComponentAdminState getAdminState() { return adminState; } http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java index 2a63bba..0d295a4 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java @@ -33,7 +33,6 @@ import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.TableGenerator; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.State; import org.apache.ambari.server.state.UpgradeState; @@ -105,10 +104,6 @@ public class HostComponentStateEntity { @Column(name = "upgrade_state", nullable = false, insertable = true, updatable = true) private UpgradeState upgradeState = UpgradeState.NONE; - @Enumerated(value = EnumType.STRING) - @Column(name = "security_state", nullable = false, insertable = true, updatable = true) - private SecurityState securityState = SecurityState.UNSECURED; - @ManyToOne @JoinColumns({ @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false), @@ -164,14 +159,6 @@ public class HostComponentStateEntity { this.currentState = currentState; } - public SecurityState getSecurityState() { - return securityState; - } - - public void setSecurityState(SecurityState securityState) { - this.securityState = securityState; - } - public UpgradeState getUpgradeState() { return upgradeState; } http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java index 0124d3e..fc26478 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java @@ -31,7 +31,6 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToOne; import org.apache.ambari.server.state.MaintenanceState; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.State; import org.apache.commons.lang.builder.EqualsBuilder; @@ -60,10 +59,6 @@ public class ServiceDesiredStateEntity { @Enumerated(value = EnumType.STRING) private MaintenanceState maintenanceState = MaintenanceState.OFF; - @Column(name = "security_state", nullable = false, insertable = true, updatable = true) - @Enumerated(value = EnumType.STRING) - private SecurityState securityState = SecurityState.UNSECURED; - @Column(name = "credential_store_enabled", nullable = false, insertable = true, updatable = true) private short credentialStoreEnabled = 0; @@ -126,14 +121,6 @@ public class ServiceDesiredStateEntity { maintenanceState = state; } - public SecurityState getSecurityState() { - return securityState; - } - - public void setSecurityState(SecurityState securityState) { - this.securityState = securityState; - } - /** * Gets a value indicating if credential store use is enabled or not. * http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/FinalizeKerberosServerAction.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/FinalizeKerberosServerAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/FinalizeKerberosServerAction.java index 10ad48b..bfd5e40 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/FinalizeKerberosServerAction.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/FinalizeKerberosServerAction.java @@ -19,7 +19,6 @@ package org.apache.ambari.server.serveraction.kerberos; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentMap; @@ -27,11 +26,6 @@ import java.util.concurrent.ConcurrentMap; import org.apache.ambari.server.AmbariException; import org.apache.ambari.server.actionmanager.HostRoleStatus; import org.apache.ambari.server.agent.CommandReport; -import org.apache.ambari.server.audit.event.kerberos.ChangeSecurityStateKerberosAuditEvent; -import org.apache.ambari.server.state.Cluster; -import org.apache.ambari.server.state.Host; -import org.apache.ambari.server.state.SecurityState; -import org.apache.ambari.server.state.ServiceComponentHost; import org.apache.ambari.server.utils.ShellCommandUtil; import org.apache.ambari.server.utils.StageUtils; import org.apache.commons.lang.StringUtils; @@ -164,39 +158,6 @@ public class FinalizeKerberosServerAction extends KerberosServerAction { @Override public CommandReport execute(ConcurrentMap requestSharedDataContext) throws AmbariException, InterruptedException { String dataDirectoryPath = getCommandParameterValue(DATA_DIRECTORY); - - // Set the ServiceComponentHost from a transitional state to the desired endpoint state - Map hosts = getClusters().getHostsForCluster(getClusterName()); - if ((hosts != null) && !hosts.isEmpty()) { - Cluster cluster = getCluster(); - for (String hostname : hosts.keySet()) { - List serviceComponentHosts = cluster.getServiceComponentHosts(hostname); - - for (ServiceComponentHost sch : serviceComponentHosts) { - SecurityState securityState = sch.getSecurityState(); - if (securityState.isTransitional()) { - String message = String.format("Setting securityState for %s/%s on host %s to state %s", - sch.getServiceName(), sch.getServiceComponentName(), sch.getHostName(), - sch.getDesiredSecurityState().toString()); - LOG.info(message); - actionLog.writeStdOut(message); - - sch.setSecurityState(sch.getDesiredSecurityState()); - ChangeSecurityStateKerberosAuditEvent auditEvent = ChangeSecurityStateKerberosAuditEvent.builder() - .withTimestamp(System.currentTimeMillis()) - .withService(sch.getServiceName()) - .withComponent(sch.getServiceComponentName()) - .withHostName(sch.getHostName()) - .withState(sch.getDesiredSecurityState().toString()) - .withRequestId(getHostRoleCommand().getRequestId()) - .withTaskId(getHostRoleCommand().getTaskId()) - .build(); - auditLog(auditEvent); - } - } - } - } - if(getKDCType(getCommandParameters()) != KDCType.NONE) { // Ensure the keytab files for the Ambari identities have the correct permissions // This is important in the event a secure cluster was created via Blueprints since some http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/PrepareDisableKerberosServerAction.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/PrepareDisableKerberosServerAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/PrepareDisableKerberosServerAction.java index c85d58f..60523cd 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/PrepareDisableKerberosServerAction.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/PrepareDisableKerberosServerAction.java @@ -34,7 +34,6 @@ import org.apache.ambari.server.controller.KerberosHelper; import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.ConfigHelper; import org.apache.ambari.server.state.PropertyInfo; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.ServiceComponent; import org.apache.ambari.server.state.ServiceComponentHost; import org.apache.ambari.server.state.StackId; @@ -85,12 +84,7 @@ public class PrepareDisableKerberosServerAction extends AbstractPrepareKerberosS kerberosDescriptor, getServiceComponentFilter(), null, identityFilter, - new KerberosHelper.Command() { - @Override - public Boolean invoke(ServiceComponentHost sch) throws AmbariException { - return (sch.getDesiredSecurityState() == SecurityState.UNSECURED) && (sch.getSecurityState() != SecurityState.UNSECURED); - } - }); + sch -> true); Map> kerberosConfigurations = new HashMap<>(); Map commandParameters = getCommandParameters(); http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/state/SecurityState.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/SecurityState.java b/ambari-server/src/main/java/org/apache/ambari/server/state/SecurityState.java deleted file mode 100644 index 8d8b136..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/SecurityState.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.state; - -import java.util.EnumSet; - -/** - * Indicates the security state of a service or component. - */ -public enum SecurityState { - /** - * Indicates that it is not known whether the service or component is secured or not - */ - UNKNOWN, - /** - * Indicates service or component is not or should not be secured - */ - UNSECURED, - /** - * Indicates component is or should be secured using Kerberos - */ - SECURED_KERBEROS, - /** - * Indicates the component is in the process of being secured - */ - SECURING, - /** - * Indicates the component is in the process of being unsecured - */ - UNSECURING, - /** - * Indicates the component is not secured due to an error condition - */ - ERROR; - - /** - * The subset of states that are considered endpoints, meaning they do not indicate the state is - * in transition. - */ - public static final EnumSet ENDPOINT_STATES = - EnumSet.of(UNKNOWN, UNSECURED, ERROR, SECURED_KERBEROS); - - /** - * The subset of states that are considered transitional, meaning they indicate a task is in - * process to reach some endpoint state - */ - public static final EnumSet TRANSITIONAL_STATES = - EnumSet.of(SECURING, UNSECURING); - - /** - * Tests this SecurityState to see if it is an endpoint state. - * - * @return true if this state is an endpoint state; otherwise false - */ - public boolean isEndpoint() { - return ENDPOINT_STATES.contains(this); - } - - /** - * Tests this SecurityState to see if it is a transitional state. - * - * @return true if this state is a transitional state; otherwise false - */ - public boolean isTransitional() { - return TRANSITIONAL_STATES.contains(this); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java index b151278..8651fee 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java @@ -47,24 +47,6 @@ public interface Service { void setDesiredState(State state); - /** - * Gets this Service's security state. - * - * @return this services desired SecurityState - */ - SecurityState getSecurityState(); - - /** - * Sets this Service's desired security state - *

- * It is expected that the new SecurityState is a valid endpoint state such that - * SecurityState.isEndpoint() == true. - * - * @param securityState the desired SecurityState for this Service - * @throws AmbariException if the new state is not an endpoint state - */ - void setSecurityState(SecurityState securityState) throws AmbariException; - StackId getDesiredStackId(); ServiceResponse convertToResponse(); http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java index 3c314d8..5ff9e37 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java @@ -96,24 +96,6 @@ public interface ServiceComponentHost { void setState(State state); /** - * Gets the current security state for this ServiceComponent - *

- * The returned SecurityState may be any endpoint or transitional state. - * - * @return the current SecurityState for this ServiceComponent - */ - SecurityState getSecurityState(); - - /** - * Sets the current security state for this ServiceComponent - *

- * The new SecurityState may be any endpoint or transitional state. - * - * @param state the current SecurityState for this ServiceComponent - */ - void setSecurityState(SecurityState state); - - /** * Gets the version of the component. * * @return component version @@ -128,27 +110,6 @@ public interface ServiceComponentHost { void setVersion(String version); /** - * Gets the desired security state for this ServiceComponent - *

- * The returned SecurityState is a valid endpoint state where - * SecurityState.isEndpoint() == true. - * - * @return the desired SecurityState for this ServiceComponent - */ - SecurityState getDesiredSecurityState(); - - /** - * Sets the desired security state for this ServiceComponent - *

- * It is expected that the new SecurityState is a valid endpoint state such that - * SecurityState.isEndpoint() == true. - * - * @param securityState the desired SecurityState for this ServiceComponent - * @throws AmbariException if the new state is not an endpoint state - */ - void setDesiredSecurityState(SecurityState securityState) throws AmbariException; - - /** * @param upgradeState the upgrade state */ void setUpgradeState(UpgradeState upgradeState); http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java index 63e1e69..4ed0429 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java @@ -276,27 +276,6 @@ public class ServiceImpl implements Service { serviceDesiredStateDAO.merge(serviceDesiredStateEntity); } - @Override - public SecurityState getSecurityState() { - ServiceDesiredStateEntity serviceDesiredStateEntity = getServiceDesiredStateEntity(); - return serviceDesiredStateEntity.getSecurityState(); - } - - @Override - public void setSecurityState(SecurityState securityState) throws AmbariException { - if(!securityState.isEndpoint()) { - throw new AmbariException("The security state must be an endpoint state"); - } - - if (LOG.isDebugEnabled()) { - LOG.debug("Setting DesiredSecurityState of Service, clusterName={}, clusterId={}, serviceName={}, oldDesiredSecurityState={}, newDesiredSecurityState={}", - cluster.getClusterName(), cluster.getClusterId(), getName(), getSecurityState(), securityState); - } - ServiceDesiredStateEntity serviceDesiredStateEntity = getServiceDesiredStateEntity(); - serviceDesiredStateEntity.setSecurityState(securityState); - serviceDesiredStateDAO.merge(serviceDesiredStateEntity); - } - /** * {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java index f9d3cfc..230b031 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java @@ -64,7 +64,6 @@ import org.apache.ambari.server.state.HostConfig; import org.apache.ambari.server.state.HostState; import org.apache.ambari.server.state.MaintenanceState; import org.apache.ambari.server.state.RepositoryVersionState; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.ServiceComponent; import org.apache.ambari.server.state.ServiceComponentHost; import org.apache.ambari.server.state.ServiceComponentHostEvent; @@ -912,61 +911,6 @@ public class ServiceComponentHostImpl implements ServiceComponentHost { } } - @Override - public SecurityState getSecurityState() { - HostComponentStateEntity stateEntity = getStateEntity(); - if (stateEntity != null) { - return stateEntity.getSecurityState(); - } else { - LOG.warn("Trying to fetch a member from an entity object that may " - + "have been previously deleted, serviceName = " + getServiceName() + ", " - + "componentName = " + getServiceComponentName() + ", " + "hostName = " + getHostName()); - } - - return null; - } - - @Override - @Transactional - public void setSecurityState(SecurityState securityState) { - HostComponentStateEntity stateEntity = getStateEntity(); - if (stateEntity != null) { - stateEntity.setSecurityState(securityState); - stateEntity = hostComponentStateDAO.merge(stateEntity); - } else { - LOG.warn("Setting a member on an entity object that may have been " - + "previously deleted, serviceName = " + getServiceName() + ", " + "componentName = " - + getServiceComponentName() + ", " + "hostName = " + getHostName()); - } - } - - @Override - public SecurityState getDesiredSecurityState() { - HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity(); - if (desiredStateEntity != null) { - return desiredStateEntity.getSecurityState(); - } else { - LOG.warn("Trying to fetch a member from an entity object that may " - + "have been previously deleted, serviceName = " + getServiceName() + ", " - + "componentName = " + getServiceComponentName() + ", " + "hostName = " + getHostName()); - } - return null; - } - - @Override - public void setDesiredSecurityState(SecurityState securityState) throws AmbariException { - if(!securityState.isEndpoint()) { - throw new AmbariException("The security state must be an endpoint state"); - } - - LOG.debug("Set DesiredSecurityState on serviceName = {} componentName = {} hostName = {} to {}", - getServiceName(), getServiceComponentName(), getHostName(), securityState); - - HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity(); - desiredStateEntity.setSecurityState(securityState); - hostComponentDesiredStateDAO.merge(desiredStateEntity); - } - /** * To be called during the upgrade of a specific Component in a host. * The potential upgrade states are NONE (default), PENDING, IN_PROGRESS, FAILED. @@ -1262,10 +1206,6 @@ public class ServiceComponentHostImpl implements ServiceComponentHost { .append(getVersion()) .append(", state=") .append(getState()) - .append(", securityState=") - .append(getSecurityState()) - .append(", desiredSecurityState=") - .append(getDesiredSecurityState()) .append(" }"); } http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java index 6caa770..5f6640a 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java @@ -77,6 +77,10 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog { protected static final String HOST_ROLE_COMMAND_TABLE = "host_role_command"; protected static final String HRC_OPS_DISPLAY_NAME_COLUMN = "ops_display_name"; protected static final String COMPONENT_TABLE = "servicecomponentdesiredstate"; + protected static final String COMPONENT_DESIRED_STATE_TABLE = "hostcomponentdesiredstate"; + protected static final String COMPONENT_STATE_TABLE = "hostcomponentstate"; + protected static final String SERVICE_DESIRED_STATE_TABLE = "servicedesiredstate"; + protected static final String SECURITY_STATE_COLUMN = "security_state"; @Inject DaoUtils daoUtils; @@ -125,6 +129,7 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog { updateStageTable(); updateClusterConfigurationTable(); addOpsDisplayNameColumnToHostRoleCommand(); + removeSecurityState(); } protected void updateStageTable() throws SQLException { @@ -311,6 +316,12 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog { new DBAccessor.DBColumnInfo(HRC_OPS_DISPLAY_NAME_COLUMN, String.class, 255, null, true)); } + private void removeSecurityState() throws SQLException { + dbAccessor.dropColumn(COMPONENT_DESIRED_STATE_TABLE, SECURITY_STATE_COLUMN); + dbAccessor.dropColumn(COMPONENT_STATE_TABLE, SECURITY_STATE_COLUMN); + dbAccessor.dropColumn(SERVICE_DESIRED_STATE_TABLE, SECURITY_STATE_COLUMN); + } + /** * Updates Log Search configs. * http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql index bbb4af0..89bc4a4 100644 --- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql +++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql @@ -187,7 +187,6 @@ CREATE TABLE hostcomponentdesiredstate ( service_name VARCHAR(255) NOT NULL, admin_state VARCHAR(32), maintenance_state VARCHAR(32) NOT NULL, - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', restart_required SMALLINT NOT NULL DEFAULT 0, CONSTRAINT PK_hostcomponentdesiredstate PRIMARY KEY (id), CONSTRAINT UQ_hcdesiredstate_name UNIQUE (component_name, service_name, host_id, cluster_id), @@ -204,7 +203,6 @@ CREATE TABLE hostcomponentstate ( host_id BIGINT NOT NULL, service_name VARCHAR(255) NOT NULL, upgrade_state VARCHAR(32) NOT NULL DEFAULT 'NONE', - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', CONSTRAINT pk_hostcomponentstate PRIMARY KEY (id), CONSTRAINT FK_hostcomponentstate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id), CONSTRAINT hstcomponentstatecomponentname FOREIGN KEY (component_name, service_name, cluster_id) REFERENCES servicecomponentdesiredstate (component_name, service_name, cluster_id)); @@ -239,7 +237,6 @@ CREATE TABLE servicedesiredstate ( desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, maintenance_state VARCHAR(32) NOT NULL, - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', credential_store_enabled SMALLINT NOT NULL DEFAULT 0, CONSTRAINT PK_servicedesiredstate PRIMARY KEY (cluster_id, service_name), CONSTRAINT FK_repo_version_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id), http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql index 5cdbd26..22dad9b 100644 --- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql +++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql @@ -207,7 +207,6 @@ CREATE TABLE hostcomponentdesiredstate ( service_name VARCHAR(100) NOT NULL, admin_state VARCHAR(32), maintenance_state VARCHAR(32) NOT NULL DEFAULT 'ACTIVE', - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', restart_required TINYINT(1) NOT NULL DEFAULT 0, CONSTRAINT PK_hostcomponentdesiredstate PRIMARY KEY (id), CONSTRAINT UQ_hcdesiredstate_name UNIQUE (component_name, service_name, host_id, cluster_id), @@ -224,7 +223,6 @@ CREATE TABLE hostcomponentstate ( host_id BIGINT NOT NULL, service_name VARCHAR(100) NOT NULL, upgrade_state VARCHAR(32) NOT NULL DEFAULT 'NONE', - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', CONSTRAINT pk_hostcomponentstate PRIMARY KEY (id), CONSTRAINT FK_hostcomponentstate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id), CONSTRAINT hstcomponentstatecomponentname FOREIGN KEY (component_name, service_name, cluster_id) REFERENCES servicecomponentdesiredstate (component_name, service_name, cluster_id)); @@ -259,7 +257,6 @@ CREATE TABLE servicedesiredstate ( desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, maintenance_state VARCHAR(32) NOT NULL DEFAULT 'ACTIVE', - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', credential_store_enabled SMALLINT NOT NULL DEFAULT 0, CONSTRAINT PK_servicedesiredstate PRIMARY KEY (cluster_id, service_name), CONSTRAINT FK_repo_version_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id), http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql index 732e2c4..ea9de0f 100644 --- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql +++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql @@ -188,7 +188,6 @@ CREATE TABLE hostcomponentdesiredstate ( service_name VARCHAR2(255) NOT NULL, admin_state VARCHAR2(32) NULL, maintenance_state VARCHAR2(32) NOT NULL, - security_state VARCHAR2(32) DEFAULT 'UNSECURED' NOT NULL, restart_required NUMBER(1) DEFAULT 0 NOT NULL, CONSTRAINT PK_hostcomponentdesiredstate PRIMARY KEY (id), CONSTRAINT UQ_hcdesiredstate_name UNIQUE (component_name, service_name, host_id, cluster_id), @@ -204,7 +203,6 @@ CREATE TABLE hostcomponentstate ( host_id NUMBER(19) NOT NULL, service_name VARCHAR2(255) NOT NULL, upgrade_state VARCHAR2(32) DEFAULT 'NONE' NOT NULL, - security_state VARCHAR2(32) DEFAULT 'UNSECURED' NOT NULL, CONSTRAINT pk_hostcomponentstate PRIMARY KEY (id), CONSTRAINT FK_hostcomponentstate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id), CONSTRAINT hstcomponentstatecomponentname FOREIGN KEY (component_name, service_name, cluster_id) REFERENCES servicecomponentdesiredstate (component_name, service_name, cluster_id)); @@ -239,7 +237,6 @@ CREATE TABLE servicedesiredstate ( desired_state VARCHAR2(255) NOT NULL, service_name VARCHAR2(255) NOT NULL, maintenance_state VARCHAR2(32) NOT NULL, - security_state VARCHAR2(32) DEFAULT 'UNSECURED' NOT NULL, credential_store_enabled SMALLINT DEFAULT 0 NOT NULL, CONSTRAINT PK_servicedesiredstate PRIMARY KEY (cluster_id, service_name), CONSTRAINT FK_repo_version_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id), http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql index 62a3f00..4f37438 100644 --- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql +++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql @@ -186,7 +186,6 @@ CREATE TABLE hostcomponentdesiredstate ( service_name VARCHAR(255) NOT NULL, admin_state VARCHAR(32), maintenance_state VARCHAR(32) NOT NULL, - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', restart_required SMALLINT NOT NULL DEFAULT 0, CONSTRAINT PK_hostcomponentdesiredstate PRIMARY KEY (id), CONSTRAINT UQ_hcdesiredstate_name UNIQUE (component_name, service_name, host_id, cluster_id), @@ -202,7 +201,6 @@ CREATE TABLE hostcomponentstate ( host_id BIGINT NOT NULL, service_name VARCHAR(255) NOT NULL, upgrade_state VARCHAR(32) NOT NULL DEFAULT 'NONE', - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', CONSTRAINT pk_hostcomponentstate PRIMARY KEY (id), CONSTRAINT FK_hostcomponentstate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id), CONSTRAINT hstcomponentstatecomponentname FOREIGN KEY (component_name, service_name, cluster_id) REFERENCES servicecomponentdesiredstate (component_name, service_name, cluster_id)); @@ -237,7 +235,6 @@ CREATE TABLE servicedesiredstate ( desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, maintenance_state VARCHAR(32) NOT NULL, - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', credential_store_enabled SMALLINT NOT NULL DEFAULT 0, CONSTRAINT PK_servicedesiredstate PRIMARY KEY (cluster_id, service_name), CONSTRAINT FK_repo_version_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id), http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql index da46ec4..aa5242c 100644 --- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql +++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql @@ -185,7 +185,6 @@ CREATE TABLE hostcomponentdesiredstate ( service_name VARCHAR(255) NOT NULL, admin_state VARCHAR(32), maintenance_state VARCHAR(32) NOT NULL DEFAULT 'ACTIVE', - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', restart_required BIT NOT NULL DEFAULT 0, CONSTRAINT PK_hostcomponentdesiredstate PRIMARY KEY (id), CONSTRAINT UQ_hcdesiredstate_name UNIQUE (component_name, service_name, host_id, cluster_id), @@ -201,7 +200,6 @@ CREATE TABLE hostcomponentstate ( host_id NUMERIC(19) NOT NULL, service_name VARCHAR(255) NOT NULL, upgrade_state VARCHAR(32) NOT NULL DEFAULT 'NONE', - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', CONSTRAINT PK_hostcomponentstate PRIMARY KEY (id), CONSTRAINT FK_hostcomponentstate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id), CONSTRAINT hstcomponentstatecomponentname FOREIGN KEY (component_name, service_name, cluster_id) REFERENCES servicecomponentdesiredstate (component_name, service_name, cluster_id)); @@ -236,7 +234,6 @@ CREATE TABLE servicedesiredstate ( desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, maintenance_state VARCHAR(32) NOT NULL DEFAULT 'ACTIVE', - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', credential_store_enabled SMALLINT NOT NULL DEFAULT 0, CONSTRAINT PK_servicedesiredstate PRIMARY KEY (cluster_id, service_name), CONSTRAINT FK_repo_version_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id), http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql index c64355e..5008471 100644 --- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql +++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql @@ -199,7 +199,6 @@ CREATE TABLE hostcomponentdesiredstate ( service_name VARCHAR(255) NOT NULL, admin_state VARCHAR(32), maintenance_state VARCHAR(32) NOT NULL, - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', restart_required BIT NOT NULL DEFAULT 0, CONSTRAINT PK_hostcomponentdesiredstate PRIMARY KEY CLUSTERED (id), CONSTRAINT UQ_hcdesiredstate_name UNIQUE NONCLUSTERED (component_name, service_name, host_id, cluster_id), @@ -216,7 +215,6 @@ CREATE TABLE hostcomponentstate ( host_id BIGINT NOT NULL, service_name VARCHAR(255) NOT NULL, upgrade_state VARCHAR(32) NOT NULL DEFAULT 'NONE', - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', CONSTRAINT PK_hostcomponentstate PRIMARY KEY CLUSTERED (id), CONSTRAINT FK_hostcomponentstate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id), CONSTRAINT hstcomponentstatecomponentname FOREIGN KEY (component_name, service_name, cluster_id) REFERENCES servicecomponentdesiredstate (component_name, service_name, cluster_id)); @@ -241,7 +239,6 @@ CREATE TABLE servicedesiredstate ( desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, maintenance_state VARCHAR(32) NOT NULL, - security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED', credential_store_enabled SMALLINT NOT NULL DEFAULT 0, CONSTRAINT PK_servicedesiredstate PRIMARY KEY CLUSTERED (cluster_id,service_name), CONSTRAINT FK_repo_version_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id), http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java index 9ef3fe1..db611fa 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java @@ -73,7 +73,6 @@ import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.Host; import org.apache.ambari.server.state.HostState; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceComponentHost; import org.apache.ambari.server.state.StackId; @@ -469,9 +468,7 @@ public class HeartbeatProcessorTest { ServiceComponentHost serviceComponentHost3 = clusters.getCluster(DummyCluster).getService(HDFS). getServiceComponent(SECONDARY_NAMENODE).getServiceComponentHost(DummyHostname1); serviceComponentHost1.setState(State.INSTALLED); - serviceComponentHost1.setSecurityState(SecurityState.UNSECURED); serviceComponentHost2.setState(State.INSTALLED); - serviceComponentHost2.setSecurityState(SecurityState.SECURING); serviceComponentHost3.setState(State.STARTING); HeartBeat hb = new HeartBeat(); @@ -516,10 +513,8 @@ public class HeartbeatProcessorTest { State componentState3 = serviceComponentHost3.getState(); assertEquals(State.STARTED, componentState1); assertEquals(State.INSTALLED, componentState2); - assertEquals(SecurityState.SECURING, serviceComponentHost2.getSecurityState()); //starting state will not be overridden by status command assertEquals(State.STARTING, componentState3); - assertEquals(SecurityState.UNSECURED, serviceComponentHost3.getSecurityState()); } http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java index 4235b11..77c90eb 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java @@ -88,7 +88,6 @@ import org.apache.ambari.server.state.Host; import org.apache.ambari.server.state.HostHealthStatus; import org.apache.ambari.server.state.HostState; import org.apache.ambari.server.state.MaintenanceState; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceComponent; import org.apache.ambari.server.state.ServiceComponentHost; @@ -945,11 +944,11 @@ public class TestHeartbeatHandler { ArrayList componentStatuses = new ArrayList<>(); ComponentStatus componentStatus1 = createComponentStatus(DummyCluster, HDFS, DummyHostStatus, State.STARTED, - SecurityState.UNSECURED, DATANODE, "{\"stackName\":\"HDP\",\"stackVersion\":\"1.3.0\"}"); + DATANODE, "{\"stackName\":\"HDP\",\"stackVersion\":\"1.3.0\"}"); ComponentStatus componentStatus2 = - createComponentStatus(DummyCluster, HDFS, DummyHostStatus, State.STARTED, SecurityState.UNSECURED, NAMENODE, ""); + createComponentStatus(DummyCluster, HDFS, DummyHostStatus, State.STARTED, NAMENODE, ""); ComponentStatus componentStatus3 = createComponentStatus(DummyCluster, HDFS, DummyHostStatus, State.INSTALLED, - SecurityState.UNSECURED, HDFS_CLIENT, "{\"stackName\":\"HDP\",\"stackVersion\":\"1.3.0\"}"); + HDFS_CLIENT, "{\"stackName\":\"HDP\",\"stackVersion\":\"1.3.0\"}"); componentStatuses.add(componentStatus1); componentStatuses.add(componentStatus2); @@ -1363,7 +1362,7 @@ public class TestHeartbeatHandler { private ComponentStatus createComponentStatus(String clusterName, String serviceName, String message, - State state, SecurityState securityState, + State state, String componentName, String stackVersion) { ComponentStatus componentStatus1 = new ComponentStatus(); componentStatus1.setClusterName(clusterName); http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java index 0196069..abab90f 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java @@ -103,7 +103,6 @@ import org.apache.ambari.server.state.Config; import org.apache.ambari.server.state.ConfigHelper; import org.apache.ambari.server.state.Host; import org.apache.ambari.server.state.HostState; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.SecurityType; import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceComponent; @@ -964,37 +963,21 @@ public class KerberosHelperTest extends EasyMockSupport { final ServiceComponentHost schKerberosClient = createMock(ServiceComponentHost.class); expect(schKerberosClient.getServiceName()).andReturn(Service.Type.KERBEROS.name()).anyTimes(); expect(schKerberosClient.getServiceComponentName()).andReturn(Role.KERBEROS_CLIENT.name()).anyTimes(); - expect(schKerberosClient.getSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); - expect(schKerberosClient.getDesiredSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); expect(schKerberosClient.getHostName()).andReturn("host1").anyTimes(); expect(schKerberosClient.getState()).andReturn(State.INSTALLED).anyTimes(); final ServiceComponentHost sch1 = createMock(ServiceComponentHost.class); expect(sch1.getServiceName()).andReturn("SERVICE1").anyTimes(); expect(sch1.getServiceComponentName()).andReturn("COMPONENT1").anyTimes(); - expect(sch1.getSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); - expect(sch1.getDesiredSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); expect(sch1.getHostName()).andReturn("host1").anyTimes(); expect(sch1.getState()).andReturn(State.INSTALLED).anyTimes(); - sch1.setDesiredSecurityState(SecurityState.SECURED_KERBEROS); - expect(expectLastCall()).once(); - sch1.setSecurityState(SecurityState.SECURING); - expect(expectLastCall()).once(); - final ServiceComponentHost sch2 = createMock(ServiceComponentHost.class); expect(sch2.getServiceName()).andReturn("SERVICE2").anyTimes(); expect(sch2.getServiceComponentName()).andReturn("COMPONENT2").anyTimes(); - expect(sch2.getSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); - expect(sch2.getDesiredSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); expect(sch2.getHostName()).andReturn("host1").anyTimes(); expect(sch2.getState()).andReturn(State.INSTALLED).anyTimes(); - sch2.setDesiredSecurityState(SecurityState.SECURED_KERBEROS); - expect(expectLastCall()).once(); - sch2.setSecurityState(SecurityState.SECURING); - expect(expectLastCall()).once(); - final Host host = createMockHost("host1"); final ServiceComponent serviceComponentKerberosClient = createNiceMock(ServiceComponent.class); @@ -1007,8 +990,6 @@ public class KerberosHelperTest extends EasyMockSupport { expect(serviceKerberos.getServiceComponents()) .andReturn(Collections.singletonMap(Role.KERBEROS_CLIENT.name(), serviceComponentKerberosClient)) .anyTimes(); - serviceKerberos.setSecurityState(SecurityState.SECURED_KERBEROS); - expectLastCall().once(); final Service service1 = createNiceMock(Service.class); expect(service1.getDesiredStackId()).andReturn(stackId).anyTimes(); @@ -1016,8 +997,6 @@ public class KerberosHelperTest extends EasyMockSupport { expect(service1.getServiceComponents()) .andReturn(Collections.emptyMap()) .anyTimes(); - service1.setSecurityState(SecurityState.SECURED_KERBEROS); - expectLastCall().once(); final Service service2 = createNiceMock(Service.class); expect(service2.getName()).andReturn("SERVICE2").anyTimes(); @@ -1025,8 +1004,6 @@ public class KerberosHelperTest extends EasyMockSupport { expect(service2.getServiceComponents()) .andReturn(Collections.emptyMap()) .anyTimes(); - service2.setSecurityState(SecurityState.SECURED_KERBEROS); - expectLastCall().once(); final Map kerberosEnvProperties = createMock(Map.class); expect(kerberosEnvProperties.get("kdc_type")).andReturn(kdcType).anyTimes(); @@ -1165,37 +1142,21 @@ public class KerberosHelperTest extends EasyMockSupport { final ServiceComponentHost schKerberosClient = createMock(ServiceComponentHost.class); expect(schKerberosClient.getServiceName()).andReturn(Service.Type.KERBEROS.name()).anyTimes(); expect(schKerberosClient.getServiceComponentName()).andReturn(Role.KERBEROS_CLIENT.name()).anyTimes(); - expect(schKerberosClient.getSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); - expect(schKerberosClient.getDesiredSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); expect(schKerberosClient.getHostName()).andReturn("host1").anyTimes(); expect(schKerberosClient.getState()).andReturn(State.INSTALLED).anyTimes(); final ServiceComponentHost sch1 = createMock(ServiceComponentHost.class); expect(sch1.getServiceName()).andReturn("SERVICE1").times(1); expect(sch1.getServiceComponentName()).andReturn("COMPONENT1").once(); - expect(sch1.getSecurityState()).andReturn(SecurityState.SECURED_KERBEROS).anyTimes(); - expect(sch1.getDesiredSecurityState()).andReturn(SecurityState.SECURED_KERBEROS).anyTimes(); expect(sch1.getHostName()).andReturn("host1").anyTimes(); expect(sch1.getState()).andReturn(State.INSTALLED).anyTimes(); - sch1.setDesiredSecurityState(SecurityState.UNSECURED); - expect(expectLastCall()).once(); - sch1.setSecurityState(SecurityState.UNSECURING); - expect(expectLastCall()).once(); - final ServiceComponentHost sch2 = createMock(ServiceComponentHost.class); expect(sch2.getServiceName()).andReturn("SERVICE2").times(1); expect(sch2.getServiceComponentName()).andReturn("COMPONENT2").anyTimes(); - expect(sch2.getSecurityState()).andReturn(SecurityState.SECURED_KERBEROS).anyTimes(); - expect(sch2.getDesiredSecurityState()).andReturn(SecurityState.SECURED_KERBEROS).anyTimes(); expect(sch2.getHostName()).andReturn("host1").anyTimes(); expect(sch2.getState()).andReturn(State.INSTALLED).anyTimes(); - sch2.setDesiredSecurityState(SecurityState.UNSECURED); - expect(expectLastCall()).once(); - sch2.setSecurityState(SecurityState.UNSECURING); - expect(expectLastCall()).once(); - final Host host = createMockHost("host1"); final ServiceComponent serviceComponentKerberosClient = createNiceMock(ServiceComponent.class); @@ -1208,8 +1169,6 @@ public class KerberosHelperTest extends EasyMockSupport { expect(serviceKerberos.getServiceComponents()) .andReturn(Collections.singletonMap(Role.KERBEROS_CLIENT.name(), serviceComponentKerberosClient)) .anyTimes(); - serviceKerberos.setSecurityState(SecurityState.UNSECURED); - expectLastCall().once(); final Service service1 = createNiceMock(Service.class); expect(service1.getDesiredStackId()).andReturn(new StackId("HDP-2.2")).anyTimes(); @@ -1217,8 +1176,6 @@ public class KerberosHelperTest extends EasyMockSupport { expect(service1.getServiceComponents()) .andReturn(Collections.emptyMap()) .anyTimes(); - service1.setSecurityState(SecurityState.UNSECURED); - expectLastCall().once(); final Service service2 = createNiceMock(Service.class); expect(service2.getDesiredStackId()).andReturn(new StackId("HDP-2.2")).anyTimes(); @@ -1226,8 +1183,6 @@ public class KerberosHelperTest extends EasyMockSupport { expect(service2.getServiceComponents()) .andReturn(Collections.emptyMap()) .anyTimes(); - service2.setSecurityState(SecurityState.UNSECURED); - expectLastCall().once(); final Map kerberosEnvProperties = createMock(Map.class); expect(kerberosEnvProperties.get("kdc_type")).andReturn("mit-kdc").anyTimes(); @@ -1378,15 +1333,11 @@ public class KerberosHelperTest extends EasyMockSupport { final ServiceComponentHost sch1 = createMock(ServiceComponentHost.class); expect(sch1.getServiceName()).andReturn("SERVICE1").anyTimes(); expect(sch1.getServiceComponentName()).andReturn("COMPONENT1").anyTimes(); - expect(sch1.getSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); - expect(sch1.getDesiredSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); expect(sch1.getHostName()).andReturn("host1").anyTimes(); final ServiceComponentHost sch2 = createMock(ServiceComponentHost.class); expect(sch2.getServiceName()).andReturn("SERVICE2").anyTimes(); expect(sch2.getServiceComponentName()).andReturn("COMPONENT2").anyTimes(); - expect(sch2.getSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); - expect(sch2.getDesiredSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); expect(sch2.getHostName()).andReturn("host1").anyTimes(); final Host host = createMockHost("host1"); @@ -1404,8 +1355,6 @@ public class KerberosHelperTest extends EasyMockSupport { sch1a = createMock(ServiceComponentHost.class); expect(sch1a.getServiceName()).andReturn("SERVICE1").anyTimes(); expect(sch1a.getServiceComponentName()).andReturn("COMPONENT1").anyTimes(); - expect(sch1a.getSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); - expect(sch1a.getDesiredSecurityState()).andReturn(SecurityState.UNSECURED).anyTimes(); expect(sch1a.getHostName()).andReturn("host2").anyTimes(); hostInvalid = createMockHost("host1"); http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/FinalizeKerberosServerActionTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/FinalizeKerberosServerActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/FinalizeKerberosServerActionTest.java index 8d6ecc3..53d2a1b 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/FinalizeKerberosServerActionTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/FinalizeKerberosServerActionTest.java @@ -19,7 +19,6 @@ package org.apache.ambari.server.serveraction.kerberos; import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; import java.io.File; import java.io.IOException; @@ -44,7 +43,6 @@ import org.apache.ambari.server.security.credential.PrincipalKeyCredential; import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.Host; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.ServiceComponentHost; import org.easymock.EasyMockSupport; import org.junit.Rule; @@ -173,13 +171,9 @@ public class FinalizeKerberosServerActionTest extends EasyMockSupport { clusterHostMap.put("host1", createMock(Host.class)); final ServiceComponentHost serviceComponentHost = createMock(ServiceComponentHost.class); - expect(serviceComponentHost.getSecurityState()).andReturn(SecurityState.SECURING).anyTimes(); expect(serviceComponentHost.getServiceName()).andReturn("SERVICE1").anyTimes(); expect(serviceComponentHost.getServiceComponentName()).andReturn("COMPONENT1A").anyTimes(); expect(serviceComponentHost.getHostName()).andReturn("host1").anyTimes(); - expect(serviceComponentHost.getDesiredSecurityState()).andReturn(SecurityState.SECURED_KERBEROS).anyTimes(); - serviceComponentHost.setSecurityState(SecurityState.SECURED_KERBEROS); - expectLastCall().once(); final List serviceComponentHosts = new ArrayList<>(); serviceComponentHosts.add(serviceComponentHost); http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java index d4b91f1..f4d0a9a 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java @@ -164,7 +164,6 @@ public class ServiceTest { Assert.assertEquals(cluster.getClusterName(), service.getCluster().getClusterName()); Assert.assertEquals(State.INIT, service.getDesiredState()); - Assert.assertEquals(SecurityState.UNSECURED, service.getSecurityState()); Assert.assertFalse( service.getDesiredStackId().getStackId().isEmpty()); @@ -291,46 +290,6 @@ public class ServiceTest { Assert.assertEquals(MaintenanceState.ON, entity.getServiceDesiredStateEntity().getMaintenanceState()); } - @Test - public void testSecurityState() throws Exception { - String serviceName = "HDFS"; - Service s = serviceFactory.createNew(cluster, serviceName, repositoryVersion); - cluster.addService(s); - - Service service = cluster.getService(serviceName); - Assert.assertNotNull(service); - - ClusterServiceDAO dao = injector.getInstance(ClusterServiceDAO.class); - ClusterServiceEntity entity = dao.findByClusterAndServiceNames(clusterName, serviceName); - Assert.assertNotNull(entity); - Assert.assertEquals(SecurityState.UNSECURED, entity.getServiceDesiredStateEntity().getSecurityState()); - Assert.assertEquals(SecurityState.UNSECURED, service.getSecurityState()); - - service.setSecurityState(SecurityState.SECURED_KERBEROS); - Assert.assertEquals(SecurityState.SECURED_KERBEROS, service.getSecurityState()); - - entity = dao.findByClusterAndServiceNames(clusterName, serviceName); - Assert.assertNotNull(entity); - Assert.assertEquals(SecurityState.SECURED_KERBEROS, entity.getServiceDesiredStateEntity().getSecurityState()); - - // Make sure there are no issues setting all endpoint values... - for(SecurityState state: SecurityState.ENDPOINT_STATES) { - service.setSecurityState(state); - Assert.assertEquals(state, service.getSecurityState()); - } - - // Make sure there transitional states are not allowed - for(SecurityState state: SecurityState.TRANSITIONAL_STATES) { - try { - service.setSecurityState(state); - Assert.fail(String.format("SecurityState %s is not a valid desired service state", state.toString())); - } - catch (AmbariException e) { - // this is acceptable - } - } - } - private void addHostToCluster(String hostname, String clusterName) throws AmbariException { clusters.addHost(hostname); http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java index dbf0c8f..54fd733 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java @@ -41,7 +41,6 @@ import org.apache.ambari.server.orm.dao.HostComponentStateDAO; import org.apache.ambari.server.orm.dao.HostDAO; import org.apache.ambari.server.orm.entities.ClusterEntity; import org.apache.ambari.server.orm.entities.HostComponentDesiredStateEntity; -import org.apache.ambari.server.orm.entities.HostComponentStateEntity; import org.apache.ambari.server.orm.entities.HostEntity; import org.apache.ambari.server.orm.entities.RepositoryVersionEntity; import org.apache.ambari.server.state.Cluster; @@ -51,7 +50,6 @@ import org.apache.ambari.server.state.ConfigFactory; import org.apache.ambari.server.state.Host; import org.apache.ambari.server.state.HostConfig; import org.apache.ambari.server.state.MaintenanceState; -import org.apache.ambari.server.state.SecurityState; import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceComponent; import org.apache.ambari.server.state.ServiceComponentFactory; @@ -196,8 +194,6 @@ public class ServiceComponentHostTest { Assert.assertEquals(State.INIT, impl.getState()); Assert.assertEquals(State.INIT, impl.getDesiredState()); - Assert.assertEquals(SecurityState.UNSECURED, impl.getSecurityState()); - Assert.assertEquals(SecurityState.UNSECURED, impl.getDesiredSecurityState()); Assert.assertEquals(c.getClusterName(), impl.getClusterName()); Assert.assertEquals(c.getClusterId(), impl.getClusterId()); Assert.assertEquals(s.getName(), impl.getServiceName()); @@ -1054,52 +1050,4 @@ public class ServiceComponentHostTest { ); Assert.assertEquals(MaintenanceState.ON, entity.getMaintenanceState()); } - - - @Test - public void testSecurityState() throws Exception { - String stackVersion = "HDP-2.0.6"; - StackId stackId = new StackId(stackVersion); - String clusterName = "c2"; - createCluster(stackId, clusterName); - - final String hostName = "h3"; - Set hostNames = new HashSet<>(); - hostNames.add(hostName); - addHostsToCluster(clusterName, hostAttributes, hostNames); - - Cluster cluster = clusters.getCluster(clusterName); - - helper.getOrCreateRepositoryVersion(stackId, stackId.getStackVersion()); - - HostEntity hostEntity = hostDAO.findByName(hostName); - ServiceComponentHost sch1 = createNewServiceComponentHost(cluster, "HDFS", "NAMENODE", hostName); - - HostComponentDesiredStateEntity entityHostComponentDesiredState; - HostComponentStateEntity entityHostComponentState; - - for(SecurityState state: SecurityState.values()) { - sch1.setSecurityState(state); - entityHostComponentState = hostComponentStateDAO.findByIndex(cluster.getClusterId(), - sch1.getServiceName(), sch1.getServiceComponentName(), hostEntity.getHostId()); - - Assert.assertNotNull(entityHostComponentState); - Assert.assertEquals(state, entityHostComponentState.getSecurityState()); - - try { - sch1.setDesiredSecurityState(state); - Assert.assertTrue(state.isEndpoint()); - entityHostComponentDesiredState = hostComponentDesiredStateDAO.findByIndex( - cluster.getClusterId(), - sch1.getServiceName(), - sch1.getServiceComponentName(), - hostEntity.getHostId() - ); - Assert.assertNotNull(entityHostComponentDesiredState); - Assert.assertEquals(state, entityHostComponentDesiredState.getSecurityState()); - } catch (AmbariException e) { - Assert.assertFalse(state.isEndpoint()); - } - } - } } http://git-wip-us.apache.org/repos/asf/ambari/blob/2258b106/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java index a7417d4..b7d78ae 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java @@ -17,6 +17,10 @@ */ package org.apache.ambari.server.upgrade; +import static org.apache.ambari.server.upgrade.UpgradeCatalog300.COMPONENT_DESIRED_STATE_TABLE; +import static org.apache.ambari.server.upgrade.UpgradeCatalog300.COMPONENT_STATE_TABLE; +import static org.apache.ambari.server.upgrade.UpgradeCatalog300.SECURITY_STATE_COLUMN; +import static org.apache.ambari.server.upgrade.UpgradeCatalog300.SERVICE_DESIRED_STATE_TABLE; import static org.easymock.EasyMock.anyObject; import static org.easymock.EasyMock.anyString; import static org.easymock.EasyMock.capture; @@ -177,6 +181,10 @@ public class UpgradeCatalog300Test { dbAccessor.addColumn(eq(UpgradeCatalog300.CLUSTER_CONFIG_TABLE), capture(clusterConfigSelectedTimestampColumn)); dbAccessor.addColumn(eq(UpgradeCatalog300.HOST_ROLE_COMMAND_TABLE), capture(hrcOpsDisplayNameColumn)); + dbAccessor.dropColumn(COMPONENT_DESIRED_STATE_TABLE, SECURITY_STATE_COLUMN); expectLastCall().once(); + dbAccessor.dropColumn(COMPONENT_STATE_TABLE, SECURITY_STATE_COLUMN); expectLastCall().once(); + dbAccessor.dropColumn(SERVICE_DESIRED_STATE_TABLE, SECURITY_STATE_COLUMN); expectLastCall().once(); + // component table Capture componentStateColumn = newCapture(); dbAccessor.addColumn(eq(UpgradeCatalog300.COMPONENT_TABLE), capture(componentStateColumn));