@@ -77,6 +77,9 @@ public class DataHubImpl implements DataHub {
7777 private AdminManager _adminManager ;
7878
7979 protected final Logger logger = LoggerFactory .getLogger (this .getClass ());
80+ private String finalFile = "final-database.json" ;
81+ private String stagingFile = "staging-database.json" ;
82+ private String jobsFile = "job-database.json" ;
8083
8184 public DataHubImpl (HubConfig hubConfig ) {
8285 if (hubConfig == null ) {
@@ -132,68 +135,55 @@ public InstallInfo isInstalled() {
132135
133136 InstallInfo installInfo = InstallInfo .create ();
134137
135- ResourcesFragment srf = null ;
136- try {
137- srf = getServerManager ().getAsXml ();
138- } catch (HttpClientErrorException e ) {
139- if (e .getStatusCode () == HttpStatus .UNAUTHORIZED ) {
140- throw new DataHubSecurityNotInstalledException ();
141- }
142- } catch (HttpServerErrorException e ) {
143- // this result comes from a disabled manage client.
144- // DHF gets this response from DHS, which has no public
145- // manage client. So we'll assume a provisioned DH exists in this case.
146- // TODO I don't know what TODO
147- if (e .getStatusCode () == HttpStatus .SERVICE_UNAVAILABLE ) {
148- return assumedProvisionedInstallInfo (installInfo );
149- }
150- else {
151- throw new DataHubConfigurationException (e );
152- }
153- } catch ( MarkLogicIOException e ) {
154- // If server is off, this happens.
155- // we don't know about install state, so don't assume it's not?
156- return assumedProvisionedInstallInfo (installInfo );
157- } catch (ResourceAccessException e ) {
158- // in ALB scenario we actually get a connection exception, not gateway
138+ if (hubConfig .getIsProvisionedEnvironment ()){
159139 return assumedProvisionedInstallInfo (installInfo );
160140 }
141+ else {
142+ ResourcesFragment srf = null ;
143+ try {
144+ srf = getServerManager ().getAsXml ();
145+ } catch (HttpClientErrorException e ) {
146+ if (e .getStatusCode () == HttpStatus .UNAUTHORIZED ) {
147+ throw new DataHubSecurityNotInstalledException ();
148+ }
149+ }
161150
162- installInfo .setAppServerExistent (DatabaseKind .STAGING , srf .resourceExists (hubConfig .getHttpName (DatabaseKind .STAGING )));
163- installInfo .setAppServerExistent (DatabaseKind .FINAL , srf .resourceExists (hubConfig .getHttpName (DatabaseKind .FINAL )));
164- installInfo .setAppServerExistent (DatabaseKind .JOB , srf .resourceExists (hubConfig .getHttpName (DatabaseKind .JOB )));
151+ installInfo .setAppServerExistent (DatabaseKind .STAGING , srf .resourceExists (hubConfig .getHttpName (DatabaseKind .STAGING )));
152+ installInfo .setAppServerExistent (DatabaseKind .FINAL , srf .resourceExists (hubConfig .getHttpName (DatabaseKind .FINAL )));
153+ installInfo .setAppServerExistent (DatabaseKind .JOB , srf .resourceExists (hubConfig .getHttpName (DatabaseKind .JOB )));
165154
166- ResourcesFragment drf = getDatabaseManager ().getAsXml ();
167- installInfo .setDbExistent (DatabaseKind .STAGING , drf .resourceExists (hubConfig .getDbName (DatabaseKind .STAGING )));
168- installInfo .setDbExistent (DatabaseKind .FINAL , drf .resourceExists (hubConfig .getDbName (DatabaseKind .FINAL )));
169- installInfo .setDbExistent (DatabaseKind .JOB , drf .resourceExists (hubConfig .getDbName (DatabaseKind .JOB )));
155+ ResourcesFragment drf = getDatabaseManager ().getAsXml ();
156+ installInfo .setDbExistent (DatabaseKind .STAGING , drf .resourceExists (hubConfig .getDbName (DatabaseKind .STAGING )));
157+ installInfo .setDbExistent (DatabaseKind .FINAL , drf .resourceExists (hubConfig .getDbName (DatabaseKind .FINAL )));
158+ installInfo .setDbExistent (DatabaseKind .JOB , drf .resourceExists (hubConfig .getDbName (DatabaseKind .JOB )));
170159
171- installInfo .setDbExistent (DatabaseKind .MODULES , drf .resourceExists (hubConfig .getDbName (DatabaseKind .MODULES )));
172- installInfo .setDbExistent (DatabaseKind .STAGING_SCHEMAS , drf .resourceExists (hubConfig .getDbName (DatabaseKind .STAGING_SCHEMAS )));
173- installInfo .setDbExistent (DatabaseKind .STAGING_TRIGGERS , drf .resourceExists (hubConfig .getDbName (DatabaseKind .STAGING_TRIGGERS )));
160+ installInfo .setDbExistent (DatabaseKind .MODULES , drf .resourceExists (hubConfig .getDbName (DatabaseKind .MODULES )));
161+ installInfo .setDbExistent (DatabaseKind .STAGING_SCHEMAS , drf .resourceExists (hubConfig .getDbName (DatabaseKind .STAGING_SCHEMAS )));
162+ installInfo .setDbExistent (DatabaseKind .STAGING_TRIGGERS , drf .resourceExists (hubConfig .getDbName (DatabaseKind .STAGING_TRIGGERS )));
174163
175- if (installInfo .isDbExistent (DatabaseKind .STAGING )) {
176- Fragment f = getDatabaseManager ().getPropertiesAsXml (hubConfig .getDbName (DatabaseKind .STAGING ));
177- installInfo .setTripleIndexOn (DatabaseKind .STAGING , Boolean .parseBoolean (f .getElementValue ("//m:triple-index" )));
178- installInfo .setCollectionLexiconOn (DatabaseKind .STAGING , Boolean .parseBoolean (f .getElementValue ("//m:collection-lexicon" )));
179- installInfo .setForestsExistent (DatabaseKind .STAGING , (f .getElements ("//m:forest" ).size () > 0 ));
180- }
164+ if (installInfo .isDbExistent (DatabaseKind .STAGING )) {
165+ Fragment f = getDatabaseManager ().getPropertiesAsXml (hubConfig .getDbName (DatabaseKind .STAGING ));
166+ installInfo .setTripleIndexOn (DatabaseKind .STAGING , Boolean .parseBoolean (f .getElementValue ("//m:triple-index" )));
167+ installInfo .setCollectionLexiconOn (DatabaseKind .STAGING , Boolean .parseBoolean (f .getElementValue ("//m:collection-lexicon" )));
168+ installInfo .setForestsExistent (DatabaseKind .STAGING , (f .getElements ("//m:forest" ).size () > 0 ));
169+ }
181170
182- if (installInfo .isDbExistent (DatabaseKind .FINAL )) {
183- Fragment f = getDatabaseManager ().getPropertiesAsXml (hubConfig .getDbName (DatabaseKind .FINAL ));
184- installInfo .setTripleIndexOn (DatabaseKind .FINAL , Boolean .parseBoolean (f .getElementValue ("//m:triple-index" )));
185- installInfo .setCollectionLexiconOn (DatabaseKind .FINAL , Boolean .parseBoolean (f .getElementValue ("//m:collection-lexicon" )));
186- installInfo .setForestsExistent (DatabaseKind .FINAL , (f .getElements ("//m:forest" ).size () > 0 ));
187- }
171+ if (installInfo .isDbExistent (DatabaseKind .FINAL )) {
172+ Fragment f = getDatabaseManager ().getPropertiesAsXml (hubConfig .getDbName (DatabaseKind .FINAL ));
173+ installInfo .setTripleIndexOn (DatabaseKind .FINAL , Boolean .parseBoolean (f .getElementValue ("//m:triple-index" )));
174+ installInfo .setCollectionLexiconOn (DatabaseKind .FINAL , Boolean .parseBoolean (f .getElementValue ("//m:collection-lexicon" )));
175+ installInfo .setForestsExistent (DatabaseKind .FINAL , (f .getElements ("//m:forest" ).size () > 0 ));
176+ }
188177
189- if (installInfo .isDbExistent (DatabaseKind .JOB )) {
190- Fragment f = getDatabaseManager ().getPropertiesAsXml (hubConfig .getDbName (DatabaseKind .JOB ));
191- installInfo .setForestsExistent (DatabaseKind .JOB , (f .getElements ("//m:forest" ).size () > 0 ));
192- }
178+ if (installInfo .isDbExistent (DatabaseKind .JOB )) {
179+ Fragment f = getDatabaseManager ().getPropertiesAsXml (hubConfig .getDbName (DatabaseKind .JOB ));
180+ installInfo .setForestsExistent (DatabaseKind .JOB , (f .getElements ("//m:forest" ).size () > 0 ));
181+ }
193182
194- logger .info (installInfo .toString ());
183+ logger .info (installInfo .toString ());
195184
196- return installInfo ;
185+ return installInfo ;
186+ }
197187 }
198188
199189 // this InstallInfo is used as a dummy to return DHS provisioned information
@@ -541,12 +531,20 @@ public void installStaging(HubDeployStatusListener listener) {
541531
542532 @ Override
543533 public void updateIndexes () {
544- AppConfig config = hubConfig .getStagingAppConfig ();
545- HubAppDeployer deployer = new HubAppDeployer (getManageClient (), getAdminManager (), null , hubConfig .newStagingClient ());
546- List <Command > commands = new ArrayList <>();
547- commands .add (new DeployHubDatabasesCommand (hubConfig ));
548- deployer .setCommands (commands );
549- deployer .deploy (config );
534+ HubAppDeployer deployer = new HubAppDeployer (getManageClient (), getAdminManager (), null , hubConfig .newStagingClient ());
535+
536+ AppConfig finalConfig = hubConfig .getFinalAppConfig ();
537+ List <Command > finalDBCommand = new ArrayList <>();
538+ finalDBCommand .add (new DeployHubDatabaseCommand (hubConfig , finalFile ));
539+ deployer .setFinalCommandsList (finalDBCommand );
540+
541+ AppConfig stagingConfig = hubConfig .getStagingAppConfig ();
542+ List <Command > stagingDBCommand = new ArrayList <>();
543+ stagingDBCommand .add (new DeployHubDatabaseCommand (hubConfig , stagingFile ));
544+ stagingDBCommand .add (new DeployHubDatabaseCommand (hubConfig , jobsFile ));
545+ deployer .setStagingCommandsList (stagingDBCommand );
546+
547+ deployer .deployAll (finalConfig , stagingConfig );
550548 }
551549
552550 /**
0 commit comments