use of org.voltdb.compiler.deploymentfile.PathsType in project voltdb by VoltDB.
the class RealVoltDB method managedPathsWithFiles.
private List<String> managedPathsWithFiles(Configuration config, DeploymentType deployment) {
ImmutableList.Builder<String> nonEmptyPaths = ImmutableList.builder();
PathsType paths = deployment.getPaths();
String voltDbRoot = getVoltDBRootPath(paths.getVoltdbroot());
String path;
if (!config.m_isEnterprise) {
return nonEmptyPaths.build();
}
if ((path = managedPathEmptyCheck(voltDbRoot, getSnapshotPath(paths.getSnapshots()))) != null)
nonEmptyPaths.add(path);
if ((path = managedPathEmptyCheck(voltDbRoot, getExportOverflowPath(paths.getExportoverflow()))) != null)
nonEmptyPaths.add(path);
if ((path = managedPathEmptyCheck(voltDbRoot, getDROverflowPath(paths.getDroverflow()))) != null)
nonEmptyPaths.add(path);
if ((path = managedPathEmptyCheck(voltDbRoot, getCommandLogPath(paths.getCommandlog()))) != null)
nonEmptyPaths.add(path);
if ((path = managedPathEmptyCheck(voltDbRoot, getCommandLogSnapshotPath(paths.getCommandlogsnapshot()))) != null)
nonEmptyPaths.add(path);
return nonEmptyPaths.build();
}
use of org.voltdb.compiler.deploymentfile.PathsType in project voltdb by VoltDB.
the class DeploymentBuilder method getXML.
/**
* Writes deployment.xml file to a temporary file. It is constructed from the passed parameters and the m_users
* field.
*
* @param voltRoot
* @param dinfo an instance {@link DeploymentInfo}
* @return deployment path
* @throws IOException
* @throws JAXBException
*/
public String getXML() {
// make sure voltroot exists
new File(m_voltRootPath).mkdirs();
org.voltdb.compiler.deploymentfile.ObjectFactory factory = new org.voltdb.compiler.deploymentfile.ObjectFactory();
// <deployment>
DeploymentType deployment = factory.createDeploymentType();
JAXBElement<DeploymentType> doc = factory.createDeployment(deployment);
// <cluster>
ClusterType cluster = factory.createClusterType();
deployment.setCluster(cluster);
cluster.setHostcount(m_hostCount);
cluster.setSitesperhost(m_sitesPerHost);
cluster.setKfactor(m_replication);
cluster.setSchema(m_useDDLSchema ? SchemaType.DDL : SchemaType.CATALOG);
// <paths>
PathsType paths = factory.createPathsType();
deployment.setPaths(paths);
Voltdbroot voltdbroot = factory.createPathsTypeVoltdbroot();
paths.setVoltdbroot(voltdbroot);
voltdbroot.setPath(m_voltRootPath);
if (m_snapshotPath != null) {
PathsType.Snapshots snapshotPathElement = factory.createPathsTypeSnapshots();
snapshotPathElement.setPath(m_snapshotPath);
paths.setSnapshots(snapshotPathElement);
}
if (m_commandLogPath != null) {
PathsType.Commandlog commandLogPathElement = factory.createPathsTypeCommandlog();
commandLogPathElement.setPath(m_commandLogPath);
paths.setCommandlog(commandLogPathElement);
}
if (m_internalSnapshotPath != null) {
PathsType.Commandlogsnapshot commandLogSnapshotPathElement = factory.createPathsTypeCommandlogsnapshot();
commandLogSnapshotPathElement.setPath(m_internalSnapshotPath);
paths.setCommandlogsnapshot(commandLogSnapshotPathElement);
}
if (m_snapshotPrefix != null) {
SnapshotType snapshot = factory.createSnapshotType();
deployment.setSnapshot(snapshot);
snapshot.setFrequency(m_snapshotFrequency);
snapshot.setPrefix(m_snapshotPrefix);
snapshot.setRetain(m_snapshotRetain);
}
SecurityType security = factory.createSecurityType();
deployment.setSecurity(security);
security.setEnabled(m_securityEnabled);
SecurityProviderString provider = SecurityProviderString.HASH;
if (m_securityEnabled)
try {
provider = SecurityProviderString.fromValue(m_securityProvider);
} catch (IllegalArgumentException shouldNotHappenSeeSetter) {
}
security.setProvider(provider);
if (m_commandLogSync != null || m_commandLogEnabled != null || m_commandLogFsyncInterval != null || m_commandLogMaxTxnsBeforeFsync != null || m_commandLogSize != null) {
CommandLogType commandLogType = factory.createCommandLogType();
if (m_commandLogSync != null) {
commandLogType.setSynchronous(m_commandLogSync.booleanValue());
}
if (m_commandLogEnabled != null) {
commandLogType.setEnabled(m_commandLogEnabled);
}
if (m_commandLogSize != null) {
commandLogType.setLogsize(m_commandLogSize);
}
if (m_commandLogFsyncInterval != null || m_commandLogMaxTxnsBeforeFsync != null) {
CommandLogType.Frequency frequency = factory.createCommandLogTypeFrequency();
if (m_commandLogFsyncInterval != null) {
frequency.setTime(m_commandLogFsyncInterval);
}
if (m_commandLogMaxTxnsBeforeFsync != null) {
frequency.setTransactions(m_commandLogMaxTxnsBeforeFsync);
}
commandLogType.setFrequency(frequency);
}
deployment.setCommandlog(commandLogType);
}
// <partition-detection>/<snapshot>
PartitionDetectionType ppd = factory.createPartitionDetectionType();
deployment.setPartitionDetection(ppd);
ppd.setEnabled(m_ppdEnabled);
// <systemsettings>
SystemSettingsType systemSettingType = factory.createSystemSettingsType();
Temptables temptables = factory.createSystemSettingsTypeTemptables();
temptables.setMaxsize(m_maxTempTableMemory);
systemSettingType.setTemptables(temptables);
if (m_snapshotPriority != null) {
SystemSettingsType.Snapshot snapshot = factory.createSystemSettingsTypeSnapshot();
snapshot.setPriority(m_snapshotPriority);
systemSettingType.setSnapshot(snapshot);
}
deployment.setSystemsettings(systemSettingType);
// <users>
if (m_users.size() > 0) {
UsersType users = factory.createUsersType();
deployment.setUsers(users);
// <user>
for (final UserInfo info : m_users) {
User user = factory.createUsersTypeUser();
users.getUser().add(user);
user.setName(info.name);
user.setPassword(info.password);
// build up user/roles.
if (info.roles.length > 0) {
final StringBuilder roles = new StringBuilder();
for (final String role : info.roles) {
if (roles.length() > 0)
roles.append(",");
roles.append(role.toLowerCase());
}
user.setRoles(roles.toString());
}
}
}
SslType ssl = factory.createSslType();
deployment.setSsl(ssl);
ssl.setEnabled(false);
// <httpd>. Disabled unless port # is configured by a testcase
HttpdType httpd = factory.createHttpdType();
deployment.setHttpd(httpd);
httpd.setEnabled(m_httpdPortNo != -1);
httpd.setPort(m_httpdPortNo);
Jsonapi json = factory.createHttpdTypeJsonapi();
httpd.setJsonapi(json);
json.setEnabled(m_jsonApiEnabled);
// <export>
ExportType export = factory.createExportType();
deployment.setExport(export);
// <dr>
if (m_drRole != DrRoleType.NONE) {
final DrType drType = factory.createDrType();
deployment.setDr(drType);
drType.setRole(m_drRole);
drType.setId(1);
}
// Have some yummy boilerplate!
String xml = null;
try {
JAXBContext context = JAXBContext.newInstance(DeploymentType.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter writer = new StringWriter();
marshaller.marshal(doc, writer);
xml = writer.toString();
} catch (Exception e) {
e.printStackTrace();
assert (false);
}
return xml;
}
use of org.voltdb.compiler.deploymentfile.PathsType in project voltdb by VoltDB.
the class RealVoltDB method pathsWithRecoverableArtifacts.
private final List<String> pathsWithRecoverableArtifacts(DeploymentType deployment) {
ImmutableList.Builder<String> nonEmptyPaths = ImmutableList.builder();
if (!MiscUtils.isPro()) {
return nonEmptyPaths.build();
}
PathsType paths = deployment.getPaths();
String voltDbRoot = getVoltDBRootPath(paths.getVoltdbroot());
String path;
if ((path = managedPathEmptyCheck(voltDbRoot, getSnapshotPath(paths.getSnapshots()))) != null)
nonEmptyPaths.add(path);
if ((path = managedPathEmptyCheck(voltDbRoot, getCommandLogPath(paths.getCommandlog()))) != null)
nonEmptyPaths.add(path);
if ((path = managedPathEmptyCheck(voltDbRoot, getCommandLogSnapshotPath(paths.getCommandlogsnapshot()))) != null)
nonEmptyPaths.add(path);
return nonEmptyPaths.build();
}
use of org.voltdb.compiler.deploymentfile.PathsType in project voltdb by VoltDB.
the class CatalogUtil method populateDefaultDeployment.
public static void populateDefaultDeployment(DeploymentType deployment) {
//partition detection
PartitionDetectionType pd = deployment.getPartitionDetection();
if (pd == null) {
pd = new PartitionDetectionType();
deployment.setPartitionDetection(pd);
}
//heartbeat
if (deployment.getHeartbeat() == null) {
HeartbeatType hb = new HeartbeatType();
deployment.setHeartbeat(hb);
}
SslType ssl = deployment.getSsl();
if (ssl == null) {
ssl = new SslType();
deployment.setSsl(ssl);
}
//httpd
HttpdType httpd = deployment.getHttpd();
if (httpd == null) {
httpd = new HttpdType();
// Find next available port starting with the default
httpd.setPort(Constants.HTTP_PORT_AUTO);
deployment.setHttpd(httpd);
}
//jsonApi
HttpdType.Jsonapi jsonApi = httpd.getJsonapi();
if (jsonApi == null) {
jsonApi = new HttpdType.Jsonapi();
httpd.setJsonapi(jsonApi);
}
//snapshot
if (deployment.getSnapshot() == null) {
SnapshotType snap = new SnapshotType();
snap.setEnabled(false);
deployment.setSnapshot(snap);
}
//Security
if (deployment.getSecurity() == null) {
SecurityType sec = new SecurityType();
deployment.setSecurity(sec);
}
//Paths
if (deployment.getPaths() == null) {
PathsType paths = new PathsType();
deployment.setPaths(paths);
}
//create paths entries
PathsType paths = deployment.getPaths();
if (paths.getVoltdbroot() == null) {
PathsType.Voltdbroot root = new PathsType.Voltdbroot();
paths.setVoltdbroot(root);
}
//snapshot
if (paths.getSnapshots() == null) {
PathsType.Snapshots snap = new PathsType.Snapshots();
paths.setSnapshots(snap);
}
if (paths.getCommandlog() == null) {
//cl
PathsType.Commandlog cl = new PathsType.Commandlog();
paths.setCommandlog(cl);
}
if (paths.getCommandlogsnapshot() == null) {
//cl snap
PathsType.Commandlogsnapshot clsnap = new PathsType.Commandlogsnapshot();
paths.setCommandlogsnapshot(clsnap);
}
if (paths.getExportoverflow() == null) {
//export overflow
PathsType.Exportoverflow exp = new PathsType.Exportoverflow();
paths.setExportoverflow(exp);
}
if (paths.getDroverflow() == null) {
final PathsType.Droverflow droverflow = new PathsType.Droverflow();
paths.setDroverflow(droverflow);
}
//Command log info
if (deployment.getCommandlog() == null) {
boolean enabled = false;
if (MiscUtils.isPro()) {
enabled = true;
}
CommandLogType cl = new CommandLogType();
cl.setEnabled(enabled);
Frequency freq = new Frequency();
cl.setFrequency(freq);
deployment.setCommandlog(cl);
}
//System settings
SystemSettingsType ss = deployment.getSystemsettings();
if (deployment.getSystemsettings() == null) {
ss = new SystemSettingsType();
deployment.setSystemsettings(ss);
}
SystemSettingsType.Elastic sse = ss.getElastic();
if (sse == null) {
sse = new SystemSettingsType.Elastic();
ss.setElastic(sse);
}
SystemSettingsType.Query query = ss.getQuery();
if (query == null) {
query = new SystemSettingsType.Query();
ss.setQuery(query);
}
SystemSettingsType.Snapshot snap = ss.getSnapshot();
if (snap == null) {
snap = new SystemSettingsType.Snapshot();
ss.setSnapshot(snap);
}
SystemSettingsType.Temptables tt = ss.getTemptables();
if (tt == null) {
tt = new SystemSettingsType.Temptables();
ss.setTemptables(tt);
}
ResourceMonitorType rm = ss.getResourcemonitor();
if (rm == null) {
rm = new ResourceMonitorType();
ss.setResourcemonitor(rm);
}
ResourceMonitorType.Memorylimit mem = rm.getMemorylimit();
if (mem == null) {
mem = new ResourceMonitorType.Memorylimit();
rm.setMemorylimit(mem);
}
}
use of org.voltdb.compiler.deploymentfile.PathsType in project voltdb by VoltDB.
the class CatalogUtil method updateRuntimeDeploymentPaths.
/**
* Get a deployment view that represents what needs to be displayed to VMC, which
* reflects the paths that are used by this cluster member and the actual number of
* hosts that belong to this cluster whether or not it was elastically expanded
* @param deployment
* @return adjusted deployment
*/
public static DeploymentType updateRuntimeDeploymentPaths(DeploymentType deployment) {
deployment = CatalogUtil.shallowClusterAndPathsClone(deployment);
PathsType paths = deployment.getPaths();
if (paths.getVoltdbroot() == null) {
PathsType.Voltdbroot root = new PathsType.Voltdbroot();
root.setPath(VoltDB.instance().getVoltDBRootPath());
paths.setVoltdbroot(root);
} else {
paths.getVoltdbroot().setPath(VoltDB.instance().getVoltDBRootPath());
}
//snapshot
if (paths.getSnapshots() == null) {
PathsType.Snapshots snap = new PathsType.Snapshots();
snap.setPath(VoltDB.instance().getSnapshotPath());
paths.setSnapshots(snap);
} else {
paths.getSnapshots().setPath(VoltDB.instance().getSnapshotPath());
}
if (paths.getCommandlog() == null) {
//cl
PathsType.Commandlog cl = new PathsType.Commandlog();
cl.setPath(VoltDB.instance().getCommandLogPath());
paths.setCommandlog(cl);
} else {
paths.getCommandlog().setPath(VoltDB.instance().getCommandLogPath());
}
if (paths.getCommandlogsnapshot() == null) {
//cl snap
PathsType.Commandlogsnapshot clsnap = new PathsType.Commandlogsnapshot();
clsnap.setPath(VoltDB.instance().getCommandLogSnapshotPath());
paths.setCommandlogsnapshot(clsnap);
} else {
paths.getCommandlogsnapshot().setPath(VoltDB.instance().getCommandLogSnapshotPath());
}
if (paths.getExportoverflow() == null) {
//export overflow
PathsType.Exportoverflow exp = new PathsType.Exportoverflow();
exp.setPath(VoltDB.instance().getExportOverflowPath());
paths.setExportoverflow(exp);
} else {
paths.getExportoverflow().setPath(VoltDB.instance().getExportOverflowPath());
}
if (paths.getDroverflow() == null) {
//dr overflow
final PathsType.Droverflow droverflow = new PathsType.Droverflow();
droverflow.setPath(VoltDB.instance().getDROverflowPath());
paths.setDroverflow(droverflow);
} else {
paths.getDroverflow().setPath(VoltDB.instance().getDROverflowPath());
}
return deployment;
}
Aggregations