Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ List<Map<String, Map<String, Object>>> populateConfigurationList(

// TODO: use multiple mpacks
BlueprintMpackInstanceEntity mpack =
((BlueprintConfigEntity)config).getBlueprintEntity().getMpackReferences().iterator().next();
((BlueprintConfigEntity)config).getBlueprintEntity().getMpackInstances().iterator().next();
StackInfo metaInfoStack;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class BlueprintEntity {
private Collection<BlueprintSettingEntity> settings = new ArrayList<>();

@OneToMany(cascade = CascadeType.ALL, mappedBy = "blueprint")
private Collection<BlueprintMpackInstanceEntity> mpackReferences = new ArrayList<>();
private Collection<BlueprintMpackInstanceEntity> mpackInstances = new ArrayList<>();


/**
Expand Down Expand Up @@ -159,11 +159,11 @@ public void setSecurityDescriptorReference(String securityDescriptorReference) {
this.securityDescriptorReference = securityDescriptorReference;
}

public Collection<BlueprintMpackInstanceEntity> getMpackReferences() {
return mpackReferences;
public Collection<BlueprintMpackInstanceEntity> getMpackInstances() {
return mpackInstances;
}

public void setMpackReferences(Collection<BlueprintMpackInstanceEntity> mpackReferences) {
this.mpackReferences = mpackReferences;
public void setMpackInstances(Collection<BlueprintMpackInstanceEntity> mpackInstances) {
this.mpackInstances = mpackInstances;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
public class BlueprintMpackConfigEntity implements BlueprintConfiguration {

@Id
@Column(name = "mpack_ref_id", nullable = false, insertable = false, updatable = false)
private Long mpackRefId;
@Column(name = "mpack_instance_id", nullable = false, insertable = false, updatable = false)
private Long mpackInstanceId;

@Id
@Column(name = "type_name", nullable = false, insertable = true, updatable = false, length = 100)
Expand All @@ -56,21 +56,21 @@ public class BlueprintMpackConfigEntity implements BlueprintConfiguration {
private String configAttributes;

@ManyToOne
@JoinColumn(name = "mpack_ref_id", referencedColumnName = "id", nullable = false)
private BlueprintMpackInstanceEntity mpackReference;
@JoinColumn(name = "mpack_instance_id", referencedColumnName = "id", nullable = false)
private BlueprintMpackInstanceEntity mpackInstance;

/**
* @return the id of the mpack referency entity this configuration belongs to
* @return the id of the mpack instance entity this configuration belongs to
*/
public Long getMpackRefId() {
return mpackRefId;
public Long getMpackInstanceId() {
return mpackInstanceId;
}

/**
* @param mpackRefId the id of the mpack referency entity this configuration belongs to
* @param mpackInstanceId the id of the instance referency entity this configuration belongs to
*/
public void setMpackRefId(Long mpackRefId) {
this.mpackRefId = mpackRefId;
public void setMpackInstanceId(Long mpackInstanceId) {
this.mpackInstanceId = mpackInstanceId;
}

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ public void setBlueprintName(String blueprintName) {
*/
@Override
public String getBlueprintName() {
return getMpackReference().getBlueprint().getBlueprintName();
return getMpackInstance().getBlueprint().getBlueprintName();
}

/**
Expand All @@ -134,16 +134,16 @@ public void setConfigAttributes(String configAttributes) {
}

/**
* @return the mpack referency entity this configuration belongs to
* @return the mpack instance entity this configuration belongs to
*/
public BlueprintMpackInstanceEntity getMpackReference() {
return mpackReference;
public BlueprintMpackInstanceEntity getMpackInstance() {
return mpackInstance;
}

/**
* @param mpackReference the mpack referency entity this configuration belongs to
* @param mpackInstance the mpack instance entity this configuration belongs to
*/
public void setMpackReference(BlueprintMpackInstanceEntity mpackReference) {
this.mpackReference = mpackReference;
public void setMpackInstance(BlueprintMpackInstanceEntity mpackInstance) {
this.mpackInstance = mpackInstance;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*/
public class BlueprintMpackConfigEntityPk {
@Id
@Column(name = "mpack_ref_id", nullable = false, insertable = true, updatable = false)
private Long mpackRefId;
@Column(name = "mpack_instance_id", nullable = false, insertable = true, updatable = false)
private Long mpackInstanceId;

@Id
@Column(name = "type_name", nullable = false, insertable = true, updatable = false, length = 100)
Expand All @@ -40,12 +40,12 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BlueprintMpackConfigEntityPk that = (BlueprintMpackConfigEntityPk) o;
return Objects.equals(mpackRefId, that.mpackRefId) &&
return Objects.equals(mpackInstanceId, that.mpackInstanceId) &&
Objects.equals(type, that.type);
}

@Override
public int hashCode() {
return Objects.hash(mpackRefId, type);
return Objects.hash(mpackInstanceId, type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
valueColumnName = "sequence_value", pkColumnValue = "blueprint_mpack_instance_id_seq", initialValue = 1)
public class BlueprintMpackInstanceEntity {
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "blueprint_mpack_reference_id_generator")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "blueprint_mpack_instance_id_generator")
@Column(name = "id", nullable = false, updatable = false)
private Long id;

Expand All @@ -61,10 +61,10 @@ public class BlueprintMpackInstanceEntity {
@Column(name = "mpack_uri")
private String mpackUri;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "mpackReference")
@OneToMany(cascade = CascadeType.ALL, mappedBy = "mpackInstance")
private Collection<BlueprintServiceEntity> serviceInstances = new ArrayList<>();

@OneToMany(cascade = CascadeType.ALL, mappedBy = "mpackReference")
@OneToMany(cascade = CascadeType.ALL, mappedBy = "mpackInstance")
private Collection<BlueprintMpackConfigEntity> configurations = new ArrayList<>();

@ManyToOne
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void setBlueprintName(String blueprintName) {
*/
@Override
public String getBlueprintName() {
return getService().getMpackReference().getBlueprint().getBlueprintName();
return getService().getMpackInstance().getBlueprint().getBlueprintName();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class BlueprintServiceEntity {
private Long id;

@ManyToOne()
@JoinColumn(name = "mpack_ref_id", referencedColumnName = "id", nullable = false)
private BlueprintMpackInstanceEntity mpackReference;
@JoinColumn(name = "mpack_instance_id", referencedColumnName = "id", nullable = false)
private BlueprintMpackInstanceEntity mpackInstance;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "service")
private Collection<BlueprintServiceConfigEntity> configurations = new ArrayList<>();
Expand All @@ -72,17 +72,17 @@ public void setId(Long id) {
}

/**
* @return the mpack reference to the mpack associated with this service
* @return the mpack instance to the mpack associated with this service
*/
public BlueprintMpackInstanceEntity getMpackReference() {
return mpackReference;
public BlueprintMpackInstanceEntity getMpackInstance() {
return mpackInstance;
}

/**
* @param mpackReference the mpack reference to the mpack associated with this service
* @param mpackInstance the mpack instance to the mpack associated with this service
*/
public void setMpackReference(BlueprintMpackInstanceEntity mpackReference) {
this.mpackReference = mpackReference;
public void setMpackInstance(BlueprintMpackInstanceEntity mpackInstance) {
this.mpackInstance = mpackInstance;
}

/**
Expand Down
35 changes: 12 additions & 23 deletions ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,6 @@ CREATE TABLE clusters (
CONSTRAINT FK_clusters_desired_stack_id FOREIGN KEY (desired_stack_id) REFERENCES stack(stack_id),
CONSTRAINT FK_clusters_resource_id FOREIGN KEY (resource_id) REFERENCES adminresource(resource_id));

CREATE TABLE configuration_base (
id BIGINT NOT NULL,
version_tag VARCHAR(255) NOT NULL,
version BIGINT NOT NULL,
type VARCHAR(255) NOT NULL,
data VARCHAR(3000) NOT NULL,
attributes VARCHAR(3000),
create_timestamp BIGINT NOT NULL,
CONSTRAINT PK_configuration_base PRIMARY KEY (id)
);

CREATE TABLE ambari_configuration (
category_name VARCHAR(100) NOT NULL,
property_name VARCHAR(100) NOT NULL,
Expand Down Expand Up @@ -145,8 +134,8 @@ CREATE TABLE servicegroupdependencies (
dependent_service_group_cluster_id BIGINT NOT NULL,
CONSTRAINT PK_servicegroupdependencies PRIMARY KEY (id),
CONSTRAINT UQ_servicegroupdependencies UNIQUE (service_group_id, service_group_cluster_id, dependent_service_group_id, dependent_service_group_cluster_id),
CONSTRAINT FK_servicegroupdependencies_service_group_cluster_id FOREIGN KEY (service_group_id, service_group_cluster_id) REFERENCES servicegroups (id, cluster_id),
CONSTRAINT FK_servicegroupdependencies_dependent_service_group_cluster_id FOREIGN KEY (dependent_service_group_id, dependent_service_group_cluster_id) REFERENCES servicegroups (id, cluster_id));
CONSTRAINT FK_svcgrpdep_svcgrp_cl_id FOREIGN KEY (service_group_id, service_group_cluster_id) REFERENCES servicegroups (id, cluster_id),
CONSTRAINT FK_svcgrpdep_dep_svcgrp_cl_id FOREIGN KEY (dependent_service_group_id, dependent_service_group_cluster_id) REFERENCES servicegroups (id, cluster_id));

CREATE TABLE clusterservices (
id BIGINT NOT NULL,
Expand Down Expand Up @@ -191,8 +180,8 @@ CREATE TABLE servicedependencies (
dependent_service_cluster_id BIGINT NOT NULL,
CONSTRAINT PK_servicedependencies PRIMARY KEY (id),
CONSTRAINT UQ_servicedependencies UNIQUE (service_id, service_group_id, service_cluster_id, dependent_service_id, dependent_service_group_id, dependent_service_cluster_id),
CONSTRAINT FK_servicedependencies_service_group_cluster_id FOREIGN KEY (service_id, service_group_id, service_cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT FK_servicedependencies_dependent_service_group_cluster_id FOREIGN KEY (dependent_service_id, dependent_service_group_id, dependent_service_cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id));
CONSTRAINT FK_svcdep_svc_grp_clstr_id FOREIGN KEY (service_id, service_group_id, service_cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT FK_svcdep_dep_scv_grp_clstr_id FOREIGN KEY (dependent_service_id, dependent_service_group_id, dependent_service_cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id));

CREATE TABLE serviceconfig (
service_config_id BIGINT NOT NULL,
Expand All @@ -207,7 +196,7 @@ CREATE TABLE serviceconfig (
note VARCHAR(3000),
CONSTRAINT PK_serviceconfig PRIMARY KEY (service_config_id),
CONSTRAINT FK_serviceconfig_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id),
CONSTRAINT FK_serviceconfig_cluster_service FOREIGN KEY (service_id, service_group_id, cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT FK_serviceconfig_clstr_svc FOREIGN KEY (service_id, service_group_id, cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT UQ_scv_service_version UNIQUE (cluster_id, service_id, version));

CREATE TABLE serviceconfighosts (
Expand Down Expand Up @@ -535,8 +524,8 @@ CREATE TABLE hostconfigmapping (
selected INTEGER NOT NULL DEFAULT 0,
user_name VARCHAR(255) NOT NULL DEFAULT '_db',
CONSTRAINT PK_hostconfigmapping PRIMARY KEY (cluster_id, host_id, type_name, create_timestamp),
CONSTRAINT FK_hostconfmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
CONSTRAINT FK_hostconfmapping_cluster_service FOREIGN KEY (service_id, service_group_id, cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT FK_hostconfmapping_clstr_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
CONSTRAINT FK_hostconfmapping_clstr_svc FOREIGN KEY (service_id, service_group_id, cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT FK_hostconfmapping_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id));

CREATE TABLE metainfo (
Expand Down Expand Up @@ -613,11 +602,11 @@ CREATE TABLE blueprint_mpack_instance(

CREATE TABLE blueprint_service (
id BIGINT NOT NULL,
mpack_ref_id BIGINT NOT NULL,
mpack_instance_id BIGINT NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this require a change in BlueprintServiceEntity, too?

@JoinColumn(name = "mpack_ref_id", referencedColumnName = "id", nullable = false)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks.

name VARCHAR(255) NOT NULL,
type VARCHAR(255) NOT NULL,
CONSTRAINT PK_blueprint_service PRIMARY KEY (id),
CONSTRAINT FK_blueprint_service_mpack_ref FOREIGN KEY (mpack_ref_id) REFERENCES blueprint_mpack_reference(id));
CONSTRAINT FK_blueprint_svc_mpack_inst FOREIGN KEY (mpack_instance_id) REFERENCES blueprint_mpack_instance(id));

CREATE TABLE blueprint_service_config (
service_id BIGINT NOT NULL,
Expand All @@ -628,12 +617,12 @@ CREATE TABLE blueprint_service_config (
CONSTRAINT FK_bp_svc_config_to_service FOREIGN KEY (service_id) REFERENCES blueprint_service (id));

CREATE TABLE blueprint_mpack_configuration (
mpack_ref_id BIGINT NOT NULL,
mpack_instance_id BIGINT NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this require a change in BlueprintMpackConfigEntity, too?

@Column(name = "mpack_ref_id", nullable = false, insertable = false, updatable = false)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks.

type_name VARCHAR(255) NOT NULL,
config_data VARCHAR(3000) NOT NULL,
config_attributes VARCHAR(3000),
CONSTRAINT PK_bp_mpack_conf PRIMARY KEY (mpack_ref_id, type_name),
CONSTRAINT FK_bp_mpack_config_to_mpack FOREIGN KEY (mpack_ref_id) REFERENCES blueprint_mpack_reference (id));
CONSTRAINT PK_bp_mpack_conf PRIMARY KEY (mpack_instance_id, type_name),
CONSTRAINT FK_bp_mpack_config_to_mpack FOREIGN KEY (mpack_instance_id) REFERENCES blueprint_mpack_instance(id));

CREATE TABLE hostgroup (
blueprint_name VARCHAR(255) NOT NULL,
Expand Down
35 changes: 12 additions & 23 deletions ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,6 @@ CREATE TABLE clusters (
CONSTRAINT FK_clusters_desired_stack_id FOREIGN KEY (desired_stack_id) REFERENCES stack(stack_id),
CONSTRAINT FK_clusters_resource_id FOREIGN KEY (resource_id) REFERENCES adminresource(resource_id));

CREATE TABLE configuration_base (
id BIGINT NOT NULL,
version_tag VARCHAR(100) NOT NULL,
version BIGINT NOT NULL,
type VARCHAR(100) NOT NULL,
data LONGTEXT NOT NULL,
attributes LONGTEXT,
create_timestamp BIGINT NOT NULL,
CONSTRAINT PK_configuration_base PRIMARY KEY (id)
);

CREATE TABLE ambari_configuration (
category_name VARCHAR(100) NOT NULL,
property_name VARCHAR(100) NOT NULL,
Expand Down Expand Up @@ -164,8 +153,8 @@ CREATE TABLE servicegroupdependencies (
dependent_service_group_cluster_id BIGINT NOT NULL,
CONSTRAINT PK_servicegroupdependencies PRIMARY KEY (id),
CONSTRAINT UQ_servicegroupdependencies UNIQUE (service_group_id, service_group_cluster_id, dependent_service_group_id, dependent_service_group_cluster_id),
CONSTRAINT FK_servicegroupdependencies_service_group_cluster_id FOREIGN KEY (service_group_id, service_group_cluster_id) REFERENCES servicegroups (id, cluster_id),
CONSTRAINT FK_servicegroupdependencies_dependent_service_group_cluster_id FOREIGN KEY (dependent_service_group_id, dependent_service_group_cluster_id) REFERENCES servicegroups (id, cluster_id));
CONSTRAINT FK_svcgrpdep_svcgrp_cl_id FOREIGN KEY (service_group_id, service_group_cluster_id) REFERENCES servicegroups (id, cluster_id),
CONSTRAINT FK_svcgrpdep_dep_svcgrp_cl_id FOREIGN KEY (dependent_service_group_id, dependent_service_group_cluster_id) REFERENCES servicegroups (id, cluster_id));

CREATE TABLE clusterservices (
id BIGINT NOT NULL,
Expand Down Expand Up @@ -210,8 +199,8 @@ CREATE TABLE servicedependencies (
dependent_service_cluster_id BIGINT NOT NULL,
CONSTRAINT PK_servicedependencies PRIMARY KEY (id),
CONSTRAINT UQ_servicedependencies UNIQUE (service_id, service_group_id, service_cluster_id, dependent_service_id, dependent_service_group_id, dependent_service_cluster_id),
CONSTRAINT FK_servicedependencies_service_group_cluster_id FOREIGN KEY (service_id, service_group_id, service_cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT FK_servicedependencies_dependent_service_group_cluster_id FOREIGN KEY (dependent_service_id, dependent_service_group_id, dependent_service_cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id));
CONSTRAINT FK_svcdep_svc_grp_clstr_id FOREIGN KEY (service_id, service_group_id, service_cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT FK_svcdep_dep_scv_grp_clstr_id FOREIGN KEY (dependent_service_id, dependent_service_group_id, dependent_service_cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id));

CREATE TABLE serviceconfig (
service_config_id BIGINT NOT NULL,
Expand All @@ -226,7 +215,7 @@ CREATE TABLE serviceconfig (
note LONGTEXT,
CONSTRAINT PK_serviceconfig PRIMARY KEY (service_config_id),
CONSTRAINT FK_serviceconfig_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id),
CONSTRAINT FK_serviceconfig_cluster_service FOREIGN KEY (service_id, service_group_id, cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT FK_serviceconfig_clstr_svc FOREIGN KEY (service_id, service_group_id, cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT UQ_scv_service_version UNIQUE (cluster_id, service_id, version));

CREATE TABLE serviceconfighosts (
Expand Down Expand Up @@ -547,8 +536,8 @@ CREATE TABLE hostconfigmapping (
version_tag VARCHAR(255) NOT NULL,
user_name VARCHAR(255) NOT NULL DEFAULT '_db',
CONSTRAINT PK_hostconfigmapping PRIMARY KEY (create_timestamp, host_id, cluster_id, type_name),
CONSTRAINT FK_hostconfmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
CONSTRAINT FK_hostconfmapping_cluster_service FOREIGN KEY (service_id, service_group_id, cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT FK_hostconfmapping_clstr_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
CONSTRAINT FK_hostconfmapping_clstr_svc FOREIGN KEY (service_id, service_group_id, cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id),
CONSTRAINT FK_hostconfmapping_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id));

CREATE TABLE metainfo (
Expand Down Expand Up @@ -632,11 +621,11 @@ CREATE TABLE blueprint_mpack_instance(

CREATE TABLE blueprint_service (
id BIGINT NOT NULL,
mpack_ref_id BIGINT NOT NULL,
mpack_instance_id BIGINT NOT NULL,
name VARCHAR(255) NOT NULL,
type VARCHAR(255) NOT NULL,
CONSTRAINT PK_blueprint_service PRIMARY KEY (id),
CONSTRAINT FK_blueprint_service_mpack_ref FOREIGN KEY (mpack_ref_id) REFERENCES blueprint_mpack_reference(id));
CONSTRAINT FK_blueprint_svc_mpack_inst FOREIGN KEY (mpack_instance_id) REFERENCES blueprint_mpack_instance(id));

CREATE TABLE blueprint_service_config (
service_id BIGINT NOT NULL,
Expand All @@ -647,12 +636,12 @@ CREATE TABLE blueprint_service_config (
CONSTRAINT FK_bp_svc_config_to_service FOREIGN KEY (service_id) REFERENCES blueprint_service (id));

CREATE TABLE blueprint_mpack_configuration (
mpack_ref_id BIGINT NOT NULL,
mpack_instance_id BIGINT NOT NULL,
type_name VARCHAR(255) NOT NULL,
config_data LONGTEXT NOT NULL,
config_attributes LONGTEXT,
CONSTRAINT PK_bp_mpack_conf PRIMARY KEY (mpack_ref_id, type_name),
CONSTRAINT FK_bp_mpack_config_to_mpack FOREIGN KEY (mpack_ref_id) REFERENCES blueprint_mpack_reference (id));
CONSTRAINT PK_bp_mpack_conf PRIMARY KEY (mpack_instance_id, type_name),
CONSTRAINT FK_bp_mpack_config_to_mpack FOREIGN KEY (mpack_instance_id) REFERENCES blueprint_mpack_instance(id));

CREATE TABLE hostgroup (
blueprint_name VARCHAR(100) NOT NULL,
Expand Down
Loading