Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor install info #763

Merged
merged 2 commits into from
Feb 27, 2018
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
63 changes: 10 additions & 53 deletions marklogic-data-hub/src/main/java/com/marklogic/hub/InstallInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,67 +14,24 @@ static InstallInfo create() {

String toString();

boolean isStagingAppServerExists();
boolean isAppServerExistent(DatabaseKind kind);

void setStagingAppServerExists(boolean stagingAppServerExists);
void setAppServerExistent(DatabaseKind kind, boolean stagingAppServerExists);

boolean isFinalAppServerExists();
boolean isDbExistent(DatabaseKind kind);

void setFinalAppServerExists(boolean finalAppServerExists);
void setDbExistent(DatabaseKind kind, boolean stagingDbExists);

boolean isTraceAppServerExists();
boolean isTripleIndexOn(DatabaseKind kind);

void setTraceAppServerExists(boolean traceAppServerExists);
void setTripleIndexOn(DatabaseKind kind, boolean stagingTripleIndexOn);

boolean isJobAppServerExists();
boolean isCollectionLexiconOn(DatabaseKind kind);

void setJobAppServerExists(boolean jobAppServerExists);
void setCollectionLexiconOn(DatabaseKind kind, boolean stagingCollectionLexiconOn);

boolean isStagingDbExists();
boolean areForestsExistent(DatabaseKind kind);

void setStagingDbExists(boolean stagingDbExists);
void setForestsExistent(DatabaseKind kind, boolean stagingForestsExist);

boolean isFinalDbExists();

void setFinalDbExists(boolean finalDbExists);

boolean isTraceDbExists();

void setTraceDbExists(boolean traceDbExists);

boolean isJobDbExists();

void setJobDbExists(boolean jobDbExists);

boolean isStagingTripleIndexOn();

void setStagingTripleIndexOn(boolean stagingTripleIndexOn);

boolean isStagingCollectionLexiconOn();

void setStagingCollectionLexiconOn(boolean stagingCollectionLexiconOn);

boolean isFinalTripleIndexOn();

void setFinalTripleIndexOn(boolean finalTripleIndexOn);

boolean isFinalCollectionLexiconOn();

void setFinalCollectionLexiconOn(boolean finalCollectionLexiconOn);

boolean isStagingForestsExist();

void setStagingForestsExist(boolean stagingForestsExist);

boolean isFinalForestsExist();

void setFinalForestsExist(boolean finalForestsExist);

boolean isTraceForestsExist();

void setTraceForestsExist(boolean traceForestsExist);

boolean isJobForestsExist();

void setJobForestsExist(boolean jobForestsExist);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.marklogic.hub.error;

import com.marklogic.hub.DatabaseKind;

public class InvalidDBOperationError extends Error {
public InvalidDBOperationError(DatabaseKind kind, String operation) {
super("Attempt to " + operation + " on the " + kind + " database");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
import com.marklogic.appdeployer.command.forests.DeployCustomForestsCommand;
import com.marklogic.client.FailedRequestException;
import com.marklogic.client.eval.ServerEvaluationCall;
import com.marklogic.hub.DataHub;
import com.marklogic.hub.FlowManager;
import com.marklogic.hub.HubConfig;
import com.marklogic.hub.InstallInfo;
import com.marklogic.hub.*;
import com.marklogic.hub.deploy.HubAppDeployer;
import com.marklogic.hub.deploy.commands.*;
import com.marklogic.hub.deploy.util.HubDeployStatusListener;
Expand Down Expand Up @@ -114,39 +111,39 @@ private ServerManager getServerManager() {
InstallInfo installInfo = InstallInfo.create();

ResourcesFragment srf = getServerManager().getAsXml();
installInfo.setStagingAppServerExists(srf.resourceExists(hubConfig.getStagingHttpName()));
installInfo.setFinalAppServerExists(srf.resourceExists(hubConfig.getFinalHttpName()));
installInfo.setTraceAppServerExists(srf.resourceExists(hubConfig.getTraceHttpName()));
installInfo.setJobAppServerExists(srf.resourceExists(hubConfig.getJobHttpName()));
installInfo.setAppServerExistent(DatabaseKind.STAGING, srf.resourceExists(hubConfig.getStagingHttpName()));
installInfo.setAppServerExistent(DatabaseKind.FINAL, srf.resourceExists(hubConfig.getFinalHttpName()));
installInfo.setAppServerExistent(DatabaseKind.TRACE, srf.resourceExists(hubConfig.getTraceHttpName()));
installInfo.setAppServerExistent(DatabaseKind.JOB, srf.resourceExists(hubConfig.getJobHttpName()));

ResourcesFragment drf = getDatabaseManager().getAsXml();
installInfo.setStagingDbExists(drf.resourceExists(hubConfig.getStagingDbName()));
installInfo.setFinalDbExists(drf.resourceExists(hubConfig.getFinalDbName()));
installInfo.setTraceDbExists(drf.resourceExists(hubConfig.getTraceDbName()));
installInfo.setJobDbExists(drf.resourceExists(hubConfig.getJobDbName()));
installInfo.setDbExistent(DatabaseKind.STAGING, drf.resourceExists(hubConfig.getStagingDbName()));
installInfo.setDbExistent(DatabaseKind.FINAL, drf.resourceExists(hubConfig.getFinalDbName()));
installInfo.setDbExistent(DatabaseKind.TRACE, drf.resourceExists(hubConfig.getTraceDbName()));
installInfo.setDbExistent(DatabaseKind.JOB, drf.resourceExists(hubConfig.getJobDbName()));

if (installInfo.isStagingDbExists()) {
if (installInfo.isDbExistent(DatabaseKind.STAGING)) {
Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getStagingDbName());
installInfo.setStagingTripleIndexOn(Boolean.parseBoolean(f.getElementValue("//m:triple-index")));
installInfo.setStagingCollectionLexiconOn(Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon")));
installInfo.setStagingForestsExist((f.getElements("//m:forest").size() > 0));
installInfo.setTripleIndexOn(DatabaseKind.STAGING, Boolean.parseBoolean(f.getElementValue("//m:triple-index")));
installInfo.setCollectionLexiconOn(DatabaseKind.STAGING, Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon")));
installInfo.setForestsExistent(DatabaseKind.STAGING, (f.getElements("//m:forest").size() > 0));
}

if (installInfo.isFinalDbExists()) {
if (installInfo.isDbExistent(DatabaseKind.FINAL)) {
Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getFinalDbName());
installInfo.setFinalTripleIndexOn(Boolean.parseBoolean(f.getElementValue("//m:triple-index")));
installInfo.setFinalCollectionLexiconOn(Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon")));
installInfo.setFinalForestsExist((f.getElements("//m:forest").size() > 0));
installInfo.setTripleIndexOn(DatabaseKind.FINAL, Boolean.parseBoolean(f.getElementValue("//m:triple-index")));
installInfo.setCollectionLexiconOn(DatabaseKind.FINAL, Boolean.parseBoolean(f.getElementValue("//m:collection-lexicon")));
installInfo.setForestsExistent(DatabaseKind.FINAL, (f.getElements("//m:forest").size() > 0));
}

if (installInfo.isTraceDbExists()) {
if (installInfo.isDbExistent(DatabaseKind.TRACE)) {
Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getTraceDbName());
installInfo.setTraceForestsExist((f.getElements("//m:forest").size() > 0));
installInfo.setForestsExistent(DatabaseKind.TRACE, (f.getElements("//m:forest").size() > 0));
}

if (installInfo.isJobDbExists()) {
if (installInfo.isDbExistent(DatabaseKind.JOB)) {
Fragment f = getDatabaseManager().getPropertiesAsXml(hubConfig.getJobDbName());
installInfo.setJobForestsExist((f.getElements("//m:forest").size() > 0));
installInfo.setForestsExistent(DatabaseKind.JOB, (f.getElements("//m:forest").size() > 0));
}

logger.info(installInfo.toString());
Expand Down
Loading