use of com.toshiba.mwcloud.gs.ContainerInfo in project YCSB by brianfrankcooper.
the class GridDBClientTest method setUp.
/**
* Create properties for configuration to get client
* Create data table to test
*/
@Before
public void setUp() throws Exception {
Properties p = new Properties();
p.setProperty("notificationAddress", NOTIFICATION_ADDR);
p.setProperty("notificationPort", NOTIFICATION_PORT);
p.setProperty("clusterName", CLUSTER_NAME);
p.setProperty("userName", USER_NAME);
p.setProperty("user", USER_NAME);
p.setProperty("password", PASS);
p.setProperty("fieldcount", String.valueOf(FIELD_COUNT));
p.setProperty("fieldlength", FIELD_LENGTH);
Measurements.setProperties(p);
final CoreWorkload workload = new CoreWorkload();
workload.init(p);
getDB(p);
// Create data table to test
// List of columns
List<ColumnInfo> columnInfoList = new ArrayList<ColumnInfo>();
ColumnInfo keyInfo = new ColumnInfo("key", GSType.STRING);
columnInfoList.add(keyInfo);
for (int i = 0; i < FIELD_COUNT; i++) {
String columnName = String.format(VALUE_COLUMN_NAME_PREFIX + "%d", i);
ColumnInfo info = new ColumnInfo(columnName, GSType.STRING);
columnInfoList.add(info);
}
containerInfo = new ContainerInfo(null, ContainerType.COLLECTION, columnInfoList, true);
try {
GridStoreFactory.getInstance().setProperties(p);
store = GridStoreFactory.getInstance().getGridStore(p);
store.putContainer(TEST_TABLE, containerInfo, false);
} catch (GSException e) {
e.printStackTrace();
throw new DBException();
}
}
use of com.toshiba.mwcloud.gs.ContainerInfo in project YCSB by brianfrankcooper.
the class GridDBClient method init.
public void init() throws DBException {
LOGGER.info("GridDBClient");
final Properties props = getProperties();
notificationAddress = props.getProperty("notificationAddress");
notificationPort = props.getProperty("notificationPort");
notificationMember = props.getProperty("notificationMember");
clusterName = props.getProperty("clusterName");
userName = props.getProperty("userName");
password = props.getProperty("password");
containerPrefix = props.getProperty("table", "usertable") + "@";
String fieldcount = props.getProperty("fieldcount");
String fieldlength = props.getProperty("fieldlength");
LOGGER.info("notificationAddress=" + notificationAddress + " notificationPort=" + notificationPort + " notificationMember=" + notificationMember);
LOGGER.info("clusterName=" + clusterName + " userName=" + userName);
LOGGER.info("fieldcount=" + fieldcount + " fieldlength=" + fieldlength);
final Properties gridstoreProp = new Properties();
if (clusterName == null || userName == null || password == null) {
LOGGER.severe("[ERROR] clusterName or userName or password argument not specified");
throw new DBException();
}
if (fieldcount == null || fieldlength == null) {
LOGGER.severe("[ERROR] fieldcount or fieldlength argument not specified");
throw new DBException();
} else {
if (!fieldcount.equals(String.valueOf(FIELD_NUM)) || !fieldlength.equals("100")) {
LOGGER.severe("[ERROR] Invalid argment: fieldcount or fieldlength");
throw new DBException();
}
}
if (notificationAddress != null) {
if (notificationPort == null) {
LOGGER.severe("[ERROR] notificationPort argument not specified");
throw new DBException();
}
// (A)multicast method
gridstoreProp.setProperty("notificationAddress", notificationAddress);
gridstoreProp.setProperty("notificationPort", notificationPort);
} else if (notificationMember != null) {
// (B)fixed list method
gridstoreProp.setProperty("notificationMember", notificationMember);
} else {
LOGGER.severe("[ERROR] notificationAddress and notificationMember argument not specified");
throw new DBException();
}
gridstoreProp.setProperty("clusterName", clusterName);
gridstoreProp.setProperty("user", userName);
gridstoreProp.setProperty("password", password);
gridstoreProp.setProperty("containerCacheSize", String.valueOf(DEFAULT_CACHE_CONTAINER_NUM));
List<ColumnInfo> columnInfoList = new ArrayList<ColumnInfo>();
ColumnInfo keyInfo = new ColumnInfo("key", SCHEMA_TYPE);
columnInfoList.add(keyInfo);
for (int i = 0; i < FIELD_NUM; i++) {
String columnName = String.format(VALUE_COLUMN_NAME_PREFIX + "%d", i);
ColumnInfo info = new ColumnInfo(columnName, SCHEMA_TYPE);
columnInfoList.add(info);
}
containerInfo = new ContainerInfo(null, ContainerType.COLLECTION, columnInfoList, true);
try {
GridStoreFactory.getInstance().setProperties(gridstoreProp);
store = GridStoreFactory.getInstance().getGridStore(gridstoreProp);
PartitionController controller = store.getPartitionController();
numContainer = controller.getPartitionCount();
for (int k = 0; k < numContainer; k++) {
String name = containerPrefix + k;
store.putContainer(name, containerInfo, false);
}
} catch (GSException e) {
LOGGER.severe("Exception: " + e.getMessage());
throw new DBException();
}
LOGGER.info("numContainer=" + numContainer + " containerCasheSize=" + String.valueOf(DEFAULT_CACHE_CONTAINER_NUM));
}
Aggregations