Skip to content

Commit

Permalink
Added a new id field to the Host catalog object. Started fixing up @S…
Browse files Browse the repository at this point in the history
…napshotSave
  • Loading branch information
apavlo committed Apr 2, 2012
1 parent a505aa4 commit 89b1148
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/catgen/spec.txt
Expand Up @@ -19,6 +19,7 @@ begin Cluster "A set of connected hosts running one or more database a
end

begin Host "A single host participating in the cluster"
int id "Unique host id"
string ipaddr "The ip address or hostname of the host"
int num_cpus "The max number of cpus on this host"
int corespercpu "The number of cores per CPU on this host"
Expand Down
6 changes: 6 additions & 0 deletions src/ee/catalog/host.cpp
Expand Up @@ -32,6 +32,7 @@ Host::Host(Catalog *catalog, CatalogType *parent, const string &path, const stri
m_cpus(catalog, this, path + "/" + "cpus")
{
CatalogValue value;
m_fields["id"] = value;
m_fields["ipaddr"] = value;
m_fields["num_cpus"] = value;
m_fields["corespercpu"] = value;
Expand All @@ -41,6 +42,7 @@ Host::Host(Catalog *catalog, CatalogType *parent, const string &path, const stri
}

void Host::update() {
m_id = m_fields["id"].intValue;
m_ipaddr = m_fields["ipaddr"].strValue.c_str();
m_num_cpus = m_fields["num_cpus"].intValue;
m_corespercpu = m_fields["corespercpu"].intValue;
Expand Down Expand Up @@ -70,6 +72,10 @@ void Host::removeChild(const std::string &collectionName, const std::string &chi
return m_cpus.remove(childName);
}

int32_t Host::id() const {
return m_id;
}

const string & Host::ipaddr() const {
return m_ipaddr;
}
Expand Down
3 changes: 3 additions & 0 deletions src/ee/catalog/host.h
Expand Up @@ -39,6 +39,7 @@ class Host : public CatalogType {
protected:
Host(Catalog * catalog, CatalogType * parent, const std::string &path, const std::string &name);

int32_t m_id;
std::string m_ipaddr;
int32_t m_num_cpus;
int32_t m_corespercpu;
Expand All @@ -53,6 +54,8 @@ class Host : public CatalogType {
virtual void removeChild(const std::string &collectionName, const std::string &childName);

public:
/** GETTER: Unique host id */
int32_t id() const;
/** GETTER: The ip address or hostname of the host */
const std::string & ipaddr() const;
/** GETTER: The max number of cpus on this host */
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/edu/brown/catalog/FixCatalog.java
Expand Up @@ -76,9 +76,10 @@ public static Catalog writeHostInfo(Catalog catalog, ClusterConfiguration cc) {
LOG.warn(String.format("Possible typo in hostname '%s'. Did you mean 'localhost'?", host));
}

String host_name = String.format("host%02d", host_id++);
String host_name = String.format("host%02d", host_id);
Host catalog_host = catalog_clus.getHosts().add(host_name);
assert (catalog_host != null);
catalog_host.setId(host_id);
catalog_host.setIpaddr(host);
LOG.debug("Created new host " + catalog_host + " on node '" + host + "'");

Expand All @@ -105,6 +106,7 @@ public static Catalog writeHostInfo(Catalog catalog, ClusterConfiguration cc) {
} // FOR

} // FOR
host_id++;
// LOG.debug("Added " + ctr + " partitions for " + catalog_host);
} // FOR
catalog_clus.setNum_partitions(partition_ctr);
Expand Down
6 changes: 6 additions & 0 deletions src/frontend/edu/brown/hstore/PartitionExecutor.java
Expand Up @@ -73,6 +73,7 @@
import org.voltdb.catalog.Catalog;
import org.voltdb.catalog.Cluster;
import org.voltdb.catalog.Database;
import org.voltdb.catalog.Host;
import org.voltdb.catalog.Partition;
import org.voltdb.catalog.PlanFragment;
import org.voltdb.catalog.Procedure;
Expand Down Expand Up @@ -502,6 +503,7 @@ public interface SystemProcedureExecutionContext {
public Database getDatabase();
public Cluster getCluster();
public Site getSite();
public Host getHost();
public ExecutionEngine getExecutionEngine();
public long getLastCommittedTxnId();
public long getNextUndo();
Expand All @@ -514,6 +516,7 @@ protected class SystemProcedureContext implements SystemProcedureExecutionContex
public Database getDatabase() { return cluster.getDatabases().get("database"); }
public Cluster getCluster() { return cluster; }
public Site getSite() { return site; }
public Host getHost() { return PartitionExecutor.this.getHost(); }
public ExecutionEngine getExecutionEngine() { return ee; }
public long getLastCommittedTxnId() { return PartitionExecutor.this.getLastCommittedTxnId(); }
public long getNextUndo() { return getNextUndoToken(); }
Expand Down Expand Up @@ -982,6 +985,9 @@ public Site getCatalogSite() {
public int getHostId() {
return (this.site.getHost().getRelativeIndex());
}
public Host getHost() {
return (this.site.getHost());
}
public int getSiteId() {
return (this.siteId);
}
Expand Down
13 changes: 13 additions & 0 deletions src/frontend/org/voltdb/catalog/Host.java
Expand Up @@ -26,6 +26,7 @@
*/
public class Host extends CatalogType {

int m_id;
String m_ipaddr = new String();
int m_num_cpus;
int m_corespercpu;
Expand All @@ -35,6 +36,7 @@ public class Host extends CatalogType {

void setBaseValues(Catalog catalog, CatalogType parent, String path, String name) {
super.setBaseValues(catalog, parent, path, name);
this.addField("id", m_id);
this.addField("ipaddr", m_ipaddr);
this.addField("num_cpus", m_num_cpus);
this.addField("corespercpu", m_corespercpu);
Expand All @@ -45,13 +47,19 @@ void setBaseValues(Catalog catalog, CatalogType parent, String path, String name
}

public void update() {
m_id = (Integer) m_fields.get("id");
m_ipaddr = (String) m_fields.get("ipaddr");
m_num_cpus = (Integer) m_fields.get("num_cpus");
m_corespercpu = (Integer) m_fields.get("corespercpu");
m_threadspercore = (Integer) m_fields.get("threadspercore");
m_memory = (Integer) m_fields.get("memory");
}

/** GETTER: Unique host id */
public int getId() {
return m_id;
}

/** GETTER: The ip address or hostname of the host */
public String getIpaddr() {
return m_ipaddr;
Expand Down Expand Up @@ -82,6 +90,11 @@ public CatalogMap<HardwareCPU> getCpus() {
return m_cpus;
}

/** SETTER: Unique host id */
public void setId(int value) {
m_id = value; m_fields.put("id", value);
}

/** SETTER: The ip address or hostname of the host */
public void setIpaddr(String value) {
m_ipaddr = value; m_fields.put("ipaddr", value);
Expand Down
12 changes: 7 additions & 5 deletions src/frontend/org/voltdb/sysprocs/SnapshotSave.java
Expand Up @@ -30,8 +30,10 @@
import org.voltdb.dtxn.DtxnConstants;
import org.voltdb.sysprocs.saverestore.SnapshotUtil;

import edu.brown.catalog.CatalogUtil;
import edu.brown.hstore.PartitionExecutor;
import edu.brown.hstore.PartitionExecutor.SystemProcedureExecutionContext;
import edu.brown.utils.CollectionUtil;
import edu.brown.utils.PartitionEstimator;

@ProcInfo(singlePartition = false)
Expand Down Expand Up @@ -169,10 +171,9 @@ private DependencySet saveTest(String file_path, String file_nonce,
VoltTable result = constructNodeResultsTable();
// Choose the lowest site ID on this host to do the file scan
// All other sites should just return empty results tables.
int host_id = context.getExecutionSite().getHostId();
Integer lowest_site_id =
VoltDB.instance().getCatalogContext().siteTracker.
getLowestLiveExecSiteIdForHost(host_id);
Host catalog_host = context.getHost();
Site catalog_site = CollectionUtil.first(CatalogUtil.getSitesForHost(catalog_host));
Integer lowest_site_id = catalog_site.getId();
if (context.getExecutionSite().getSiteId() == lowest_site_id)
{
LOG.trace("Checking feasibility of save with path and nonce: "
Expand Down Expand Up @@ -221,7 +222,7 @@ else if (!saveFilePath.getParentFile().canWrite())
"RESULTED IN IOException: " + ex.getMessage();
}
}
result.addRow(Integer.parseInt(context.getSite().getHost().getTypeName()),
result.addRow(catalog_host.getId(),
hostname,
table.getTypeName(),
file_valid,
Expand Down Expand Up @@ -286,6 +287,7 @@ public VoltTable[] run(String path, String nonce, long block) throws VoltAbortEx
// See if we think the save will succeed
VoltTable[] results;
results = performSaveFeasibilityWork(path, nonce);
LOG.info("performSaveFeasibilityWork Results:\n" + results);

// Test feasibility results for fail
while (results[0].advanceRow())
Expand Down

0 comments on commit 89b1148

Please sign in to comment.