use of it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException in project SEPA by arces-wot.
the class Consumer method onBrokenConnection.
@Override
public void onBrokenConnection(ErrorResponse errorResponse) {
logger.warn("onBrokenConnection");
subscribed = false;
// Auto reconnection mechanism
if (appProfile.reconnect()) {
try {
protocol = new WebsocketSubscriptionProtocol(appProfile.getSubscribeHost(subID), appProfile.getSubscribePort(subID), appProfile.getSubscribePath(subID), this, sm);
client = new SPARQL11SEProtocol(protocol, sm);
} catch (SEPASecurityException | SEPAProtocolException e1) {
logger.error(e1.getMessage());
return;
}
while (!subscribed) {
try {
subscribe(TIMEOUT, NRETRY);
} catch (SEPASecurityException | SEPAPropertiesException | SEPAProtocolException | SEPABindingsException e) {
logger.error(e.getMessage());
if (logger.isTraceEnabled())
e.printStackTrace();
}
try {
synchronized (client) {
client.wait(TIMEOUT);
}
} catch (InterruptedException e) {
logger.error(e.getMessage());
if (logger.isTraceEnabled())
e.printStackTrace();
}
}
}
}
use of it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException in project SEPA by arces-wot.
the class ForcedBindings method setBindingValue.
/**
* Sets the binding value.
*
* @param variable the variable
* @param value the value
* @param datatype the datatype
*/
public void setBindingValue(String variable, String value, String datatype) throws SEPABindingsException {
if (variable == null || value == null)
throw new SEPABindingsException("One or more arguments are null");
try {
solution.getAsJsonObject(variable).add("value", new JsonPrimitive(value));
solution.getAsJsonObject(variable).add("datatype", new JsonPrimitive(datatype));
} catch (Exception e) {
throw new SEPABindingsException(String.format("Variable not found: %s", variable));
}
}
use of it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException in project SEPA by arces-wot.
the class ITPattern method genericClientDoubleSubscribe.
@RepeatedTest(ConfigurationProvider.REPEATED_TEST)
@Timeout(10)
public void genericClientDoubleSubscribe() {
try {
genericClient = new GenericClient(provider.getJsap(), handler);
genericClient.subscribe("RANDOM", null, "first", provider.TIMEOUT, provider.NRETRY);
genericClient.subscribe("RANDOM1", null, "second", provider.TIMEOUT, provider.NRETRY);
handler.waitSubscribes(2);
Response ret = genericClient.update("RANDOM", null, provider.TIMEOUT, provider.NRETRY);
assertFalse(ret.isError(), ret.toString());
ret = genericClient.update("RANDOM1", null, provider.TIMEOUT, provider.NRETRY);
assertFalse(ret.isError(), ret.toString());
handler.waitEvents(4);
genericClient.unsubscribe(handler.getSpuid("first"), provider.TIMEOUT, provider.NRETRY);
genericClient.unsubscribe(handler.getSpuid("second"), provider.TIMEOUT, provider.NRETRY);
handler.waitUnsubscribes(2);
} catch (SEPAProtocolException | SEPASecurityException | SEPAPropertiesException | SEPABindingsException | InterruptedException | IOException e) {
e.printStackTrace();
assertFalse(true, e.getMessage());
}
}
use of it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException in project SEPA by arces-wot.
the class StressUsingPAC method subscribeAndUpdateRaceDetection.
@RepeatedTest(ConfigurationProvider.REPEATED_TEST)
public // @Timeout(10)
void subscribeAndUpdateRaceDetection() throws InterruptedException, SEPASecurityException, IOException, SEPAPropertiesException, SEPAProtocolException, SEPABindingsException {
Thread pub = new Thread() {
public void run() {
for (int i = 0; i < 500; i++) {
try {
randomProducer.update(provider.TIMEOUT, provider.NRETRY);
} catch (SEPASecurityException | SEPAPropertiesException | SEPABindingsException | SEPAProtocolException e) {
assertFalse(true, "Failed on update: " + i + " " + e.getMessage());
}
}
}
};
Thread sub = new Thread() {
public void run() {
for (int i = 0; i < 500; i++) {
try {
consumerRandom1 = new ConsumerTestUnit(provider, "RANDOM1");
consumerRandom1.syncSubscribe(provider.TIMEOUT, provider.NRETRY);
consumerRandom1.close();
consumerAll = new ConsumerTestUnit(provider, "ALL");
consumerAll.syncSubscribe(provider.TIMEOUT, provider.NRETRY);
consumerAll.close();
} catch (SEPASecurityException | SEPAPropertiesException | SEPABindingsException | SEPAProtocolException | IOException | InterruptedException e) {
assertFalse(true, "Failed on subscribe: " + i + " " + e.getMessage());
}
}
}
};
pub.start();
sub.start();
synchronized (pub) {
pub.wait();
}
synchronized (sub) {
sub.wait();
}
}
use of it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException in project SEPA by arces-wot.
the class AggregatorTestUnit method onResults.
@Override
public void onResults(ARBindingsResults results) {
synchronized (this) {
notificationReceived = true;
notify();
}
try {
Response ret = update();
if (ret.isError())
logger.error(ret);
} catch (SEPASecurityException | SEPAProtocolException | SEPAPropertiesException | SEPABindingsException e) {
logger.error(e);
}
}
Aggregations