use of org.apache.phoenix.pherf.exception.PherfException in project phoenix by apache.
the class ResourceList method getResourcesPaths.
/**
* for all elements of java.class.path get a Collection of resources Pattern
* pattern = Pattern.compile(".*"); gets all resources
*
* @param pattern the pattern to match
* @return the resources in the order they are found
*/
private Collection<Path> getResourcesPaths(final Pattern pattern) throws Exception {
final String classPath = System.getProperty("java.class.path", ".");
final String[] classPathElements = classPath.split(":");
List<String> strResources = new ArrayList<>();
Collection<Path> paths = new ArrayList<>();
// Get resources as strings.
for (final String element : classPathElements) {
strResources.addAll(getResources(element, pattern));
}
// Convert resources to URL
for (String resource : strResources) {
URL url = null;
URI uri = null;
Path path = null;
String rName = rootResourceDir + resource;
logger.debug("Trying with the root append.");
url = ResourceList.class.getResource(rName);
if (url == null) {
logger.debug("Failed! Must be using a jar. Trying without the root append.");
url = ResourceList.class.getResource(resource);
if (url == null) {
throw new PherfException("Could not load resources: " + rName);
}
final String[] splits = url.toString().split("!");
uri = URI.create(splits[0]);
path = (splits.length < 2) ? Paths.get(uri) : Paths.get(splits[1]);
} else {
path = Paths.get(url.toURI());
}
logger.debug("Found the correct resource: " + path.toString());
paths.add(path);
}
return paths;
}
use of org.apache.phoenix.pherf.exception.PherfException in project phoenix by apache.
the class WriteWorkload method getBatches.
private List<Future<Info>> getBatches(DataLoadThreadTime dataLoadThreadTime, Scenario scenario) throws Exception {
RowCalculator rowCalculator = new RowCalculator(getThreadPoolSize(), scenario.getRowCount());
List<Future<Info>> writeBatches = new ArrayList<>();
for (int i = 0; i < getThreadPoolSize(); i++) {
List<Column> phxMetaCols = pUtil.getColumnsFromPhoenix(scenario.getSchemaName(), scenario.getTableNameWithoutSchemaName(), pUtil.getConnection(scenario.getTenantId()));
int threadRowCount = rowCalculator.getNext();
logger.info("Kick off thread (#" + i + ")for upsert with (" + threadRowCount + ") rows.");
Future<Info> write = upsertData(scenario, phxMetaCols, scenario.getTableName(), threadRowCount, dataLoadThreadTime, this.useBatchApi);
writeBatches.add(write);
}
if (writeBatches.isEmpty()) {
throw new PherfException("Holy shit snacks! Throwing up hands in disbelief and exiting. Could not write data for some unknown reason.");
}
return writeBatches;
}
Aggregations