use of org.apache.asterix.common.exceptions.AsterixException in project asterixdb by apache.
the class AbstractAsterixListIterator method reset.
@Override
public void reset() throws HyracksDataException {
count = 0;
try {
pos = getItemOffset(data, startOff, count);
nextPos = startOff + listLength;
if (count + 1 < numberOfItems) {
nextPos = getItemOffset(data, startOff, count + 1);
}
itemLen = nextPos - pos;
} catch (AsterixException e) {
throw new HyracksDataException(e);
}
}
use of org.apache.asterix.common.exceptions.AsterixException in project asterixdb by apache.
the class TwitterUtil method initializeConfigurationWithAuthInfo.
public static void initializeConfigurationWithAuthInfo(Map<String, String> configuration) throws AsterixException {
String authMode = configuration.get(AuthenticationConstants.AUTHENTICATION_MODE);
if (authMode == null) {
authMode = AuthenticationConstants.AUTHENTICATION_MODE_FILE;
}
try {
switch(authMode) {
case AuthenticationConstants.AUTHENTICATION_MODE_FILE:
Properties prop = new Properties();
String authFile = configuration.get(AuthenticationConstants.OAUTH_AUTHENTICATION_FILE);
if (authFile == null) {
authFile = AuthenticationConstants.DEFAULT_AUTH_FILE;
}
InputStream in = TwitterUtil.class.getResourceAsStream(authFile);
prop.load(in);
in.close();
configuration.put(AuthenticationConstants.OAUTH_CONSUMER_KEY, prop.getProperty(AuthenticationConstants.OAUTH_CONSUMER_KEY));
configuration.put(AuthenticationConstants.OAUTH_CONSUMER_SECRET, prop.getProperty(AuthenticationConstants.OAUTH_CONSUMER_SECRET));
configuration.put(AuthenticationConstants.OAUTH_ACCESS_TOKEN, prop.getProperty(AuthenticationConstants.OAUTH_ACCESS_TOKEN));
configuration.put(AuthenticationConstants.OAUTH_ACCESS_TOKEN_SECRET, prop.getProperty(AuthenticationConstants.OAUTH_ACCESS_TOKEN_SECRET));
break;
case AuthenticationConstants.AUTHENTICATION_MODE_EXPLICIT:
break;
}
} catch (Exception e) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning("unable to load authentication credentials from auth.properties file" + "credential information will be obtained from adapter's configuration");
}
}
}
use of org.apache.asterix.common.exceptions.AsterixException in project asterixdb by apache.
the class TwitterUtil method getBoundingBoxes.
/**
* Gets more than one bounding box from a sequences of coordinates
* (following Twitter formats) + predefined location names, as US and EU.
* E.g., for EU and US, we would use -29.7, 79.2, 36.7, 72.0; -124.848974,
* -66.885444, 24.396308, 49.384358.
*
* @param locationValue
* String value of the location coordinates or names (comma-separated)
* @return
* @throws AsterixException
*/
public static double[][] getBoundingBoxes(String locationValue) throws AsterixException {
double[][] locations = null;
String coordRegex = "^((((\\-?\\d+\\.\\d+),\\s*){3}(\\-?\\d+\\.\\d+)|\\w+);\\s*)*(((\\-?\\d+\\.\\d+),\\s*){3}(\\-?\\d+\\.\\d+)|\\w+)$";
Pattern p = Pattern.compile(coordRegex);
Matcher m = p.matcher(locationValue);
if (m.matches()) {
String[] locationStrings = locationValue.trim().split(";\\s*");
locations = new double[locationStrings.length * 2][2];
for (int i = 0; i < locationStrings.length; i++) {
if (locationStrings[i].contains(",")) {
String[] coordinatesString = locationStrings[i].split(",");
for (int k = 0; k < 2; k++) {
for (int l = 0; l < 2; l++) {
try {
locations[2 * i + k][l] = Double.parseDouble(coordinatesString[2 * k + l]);
} catch (NumberFormatException ne) {
throw new AsterixException("Incorrect coordinate value " + coordinatesString[2 * k + l]);
}
}
}
} else if (GeoConstants.boundingBoxes.containsKey(locationStrings[i])) {
// Only add known locations
double[][] loc = GeoConstants.boundingBoxes.get(locationStrings[i]);
for (int k = 0; k < 2; k++) {
for (int l = 0; l < 2; l++) {
locations[2 * i + k][l] = loc[k][l];
}
}
}
}
}
return locations;
}
use of org.apache.asterix.common.exceptions.AsterixException in project asterixdb by apache.
the class ClusterManager method addNode.
@Override
public void addNode(ICcApplicationContext appCtx, Node node) throws AsterixException {
try {
Cluster cluster = ClusterProperties.INSTANCE.getCluster();
List<Pattern> pattern = new ArrayList<>();
String asterixInstanceName = appCtx.getMetadataProperties().getInstanceName();
Patterns prepareNode = PatternCreator.INSTANCE.createPrepareNodePattern(asterixInstanceName, ClusterProperties.INSTANCE.getCluster(), node);
cluster.getNode().add(node);
client.submit(prepareNode);
ExternalProperties externalProps = appCtx.getExternalProperties();
AsterixEventServiceUtil.poulateClusterEnvironmentProperties(cluster, externalProps.getCCJavaParams(), externalProps.getNCJavaParams());
pattern.clear();
String ccHost = cluster.getMasterNode().getClusterIp();
String hostId = node.getId();
String nodeControllerId = asterixInstanceName + "_" + node.getId();
String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
Pattern startNC = PatternCreator.INSTANCE.createNCStartPattern(ccHost, hostId, nodeControllerId, iodevices, false);
pattern.add(startNC);
Patterns startNCPattern = new Patterns(pattern);
client.submit(startNCPattern);
removeNode(cluster.getSubstituteNodes().getNode(), node);
AsterixInstance instance = lookupService.getAsterixInstance(cluster.getInstanceName());
instance.getCluster().getNode().add(node);
removeNode(instance.getCluster().getSubstituteNodes().getNode(), node);
lookupService.updateAsterixInstance(instance);
} catch (Exception e) {
throw new AsterixException(e);
}
}
use of org.apache.asterix.common.exceptions.AsterixException in project asterixdb by apache.
the class AsterixProperties method registerConfigOptions.
public static void registerConfigOptions(IConfigManager configManager) {
configManager.register(NodeProperties.Option.class, CompilerProperties.Option.class, MetadataProperties.Option.class, ExternalProperties.Option.class, ActiveProperties.Option.class, MessagingProperties.Option.class, ReplicationProperties.Option.class, StorageProperties.Option.class, TransactionProperties.Option.class);
// we need to process the old-style asterix config before we apply defaults!
configManager.addConfigurator(IConfigManager.ConfiguratorMetric.APPLY_DEFAULTS.metric() - 1, () -> {
try {
PropertiesAccessor.getInstance(configManager.getAppConfig());
} catch (AsterixException e) {
throw new HyracksDataException(e);
}
});
}
Aggregations