io.siddhi.core.exception.ConnectionUnavailableException Java Examples

The following examples show how to use io.siddhi.core.exception.ConnectionUnavailableException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestStoreContainingInMemoryTable.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
protected RecordIterator<Object[]> find(Map<String, Object> findConditionParameterMap,
                                        CompiledCondition compiledCondition) throws ConnectionUnavailableException {
    if (findMatchingEvent == null) {
        findMatchingEvent = new StateEvent(1, 0);
    }
    try {
        StreamEvent outEvent = inMemoryTable.find(compiledCondition, findMatchingEvent);
        List<Object[]> objects = new LinkedList<>();
        if (outEvent != null) {
            while (outEvent.hasNext()) {
                objects.add(outEvent.getOutputData());
                outEvent = outEvent.getNext();
            }
            objects.add(outEvent.getOutputData());
        }
        return new TestStoreWithCacheIterator(objects.iterator());
    } finally {
        findMatchingEvent = null;
    }
}
 
Example #2
Source File: JoinProcessor.java    From siddhi with Apache License 2.0 6 votes vote down vote up
private StreamEvent query(StateEvent joinStateEvent) throws SiddhiAppRuntimeException {
    Table table = ((TableWindowProcessor) findableProcessor).getTable();
    if (table.getIsConnected()) {
        try {
            return ((QueryableProcessor) findableProcessor).query(joinStateEvent, compiledCondition,
                    compiledSelection, expectedOutputAttributes);
        } catch (ConnectionUnavailableException e) {
            table.setIsConnectedToFalse();
            table.connectWithRetry();
            return query(joinStateEvent);
        }
    } else if (table.getIsTryingToConnect()) {
        log.warn("Error while performing query '" + queryName + "' within Siddhi app '" + siddhiAppName +
                "' for event '" + joinStateEvent + "', operation busy waiting at Table '" +
                table.getTableDefinition().getId() + "' as its trying to reconnect!");
        table.waitWhileConnect();
        log.info("Table '" + table.getTableDefinition().getId() + "' has become available for query '" +
                queryName + "' within Siddhi app '" + siddhiAppName + "for matching event '" +
                joinStateEvent + "'");
        return query(joinStateEvent);
    } else {
        table.connectWithRetry();
        return query(joinStateEvent);
    }
}
 
Example #3
Source File: AbstractQueryableRecordTable.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
protected void connectAndLoadCache() throws ConnectionUnavailableException {
    connect();
    if (cacheEnabled) {
        ((CacheTable) cacheTable).deleteAll();
        StateEvent stateEventForCaching = new StateEvent(1, 0);
        StreamEvent preLoadedData;
        queryStoreWithoutCheckingCache.set(Boolean.TRUE);
        try {
            preLoadedData = query(stateEventForCaching, compiledConditionForCaching,
                    compiledSelectionForCaching, outputAttributesForCaching);
        } finally {
            queryStoreWithoutCheckingCache.set(Boolean.FALSE);
        }

        if (preLoadedData != null) {
            ((CacheTable) cacheTable).addStreamEventUptoMaxSize(preLoadedData);
        }
        if (cacheExpiryEnabled) {
            siddhiAppContext.getScheduledExecutorService().scheduleAtFixedRate(
                    new CacheExpirer(retentionPeriod, cacheTable, tableMap, this, siddhiAppContext).
                            generateCacheExpirer(), 0, purgeInterval, TimeUnit.MILLISECONDS);
        }
    }
}
 
Example #4
Source File: TestAsyncInMemory.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    try {
        if (fail || failOnce) {
            failOnce = false;
            numberOfErrorOccurred++;
            throw new ConnectionUnavailableException("Connection unavailable during publishing");
        }
        sink.send(payload, dynamicOptions, state);
    } catch (Throwable e) {
        if (failRuntime) {
            onError(payload, dynamicOptions, new SiddhiAppRuntimeException(e.getMessage(), e));
        } else {
            onError(payload, dynamicOptions, new ConnectionUnavailableException(e.getMessage(), e));
        }
    }
}
 
Example #5
Source File: AbstractRecordTable.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
public void add(ComplexEventChunk<StreamEvent> addingEventChunk) throws ConnectionUnavailableException {
    List<Object[]> records = new ArrayList<>();
    addingEventChunk.reset();
    long timestamp = 0L;
    while (addingEventChunk.hasNext()) {
        StreamEvent event = addingEventChunk.next();
        records.add(event.getOutputData());
        timestamp = event.getTimestamp();
    }
    if (recordTableHandler != null) {
        recordTableHandler.add(timestamp, records);
    } else {
        add(records);
    }
}
 
Example #6
Source File: TestStoreForCachePreLoading.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
protected RecordIterator<Object[]> find(Map<String, Object> findConditionParameterMap,
                                        CompiledCondition compiledCondition) throws ConnectionUnavailableException {
    if (findMatchingEvent == null) {
        findMatchingEvent = new StateEvent(1, 0);
    }
    try {
        StreamEvent outEvent = inMemoryTable.find(compiledCondition, findMatchingEvent);
        List<Object[]> objects = new LinkedList<>();
        if (outEvent != null) {
            while (outEvent.hasNext()) {
                objects.add(outEvent.getOutputData());
                outEvent = outEvent.getNext();
            }
            objects.add(outEvent.getOutputData());
        }
        return new TestStoreWithCacheIterator(objects.iterator());
    } finally {
        findMatchingEvent = null;
    }
}
 
Example #7
Source File: KafkaMultiDCSource.java    From siddhi-io-kafka with Apache License 2.0 6 votes vote down vote up
@Override
public void connect(ConnectionCallback connectionCallback, KafkaMultiDCSourceState kafkaMultiDCSourceState)
        throws ConnectionUnavailableException {
    StringBuilder errorMessage = new StringBuilder();
    for (Map.Entry entry : sources.entrySet()) {
        try {
            KafkaSource.KafkaSourceState kafkaSourceState = kafkaMultiDCSourceState.kafkaSourceStateMap.
                    get(entry.getKey().toString());
            ((KafkaSource) entry.getValue()).connect((Source.ConnectionCallback) connectionCallback,
                    kafkaSourceState);
            LOG.info("Connect to bootstrap server " + entry.getKey());
        } catch (ConnectionUnavailableException e) {
            errorMessage.append("Error occurred while connecting to ")
                    .append(entry.getKey()).append(":")
                    .append(e.getMessage()).append("\n");
        }
    }

    if (!errorMessage.toString().isEmpty()) {
        LOG.error("Error while trying to connect boot strap server(s): " + errorMessage.toString());
        throw new ConnectionUnavailableException(errorMessage.toString());
    }
}
 
Example #8
Source File: AbstractRecordTable.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public void delete(ComplexEventChunk<StateEvent> deletingEventChunk, CompiledCondition compiledCondition)
        throws ConnectionUnavailableException {
    RecordStoreCompiledCondition recordStoreCompiledCondition =
            ((RecordStoreCompiledCondition) compiledCondition);
    List<Map<String, Object>> deleteConditionParameterMaps = new ArrayList<>();
    deletingEventChunk.reset();
    long timestamp = 0L;
    while (deletingEventChunk.hasNext()) {
        StateEvent stateEvent = deletingEventChunk.next();

        Map<String, Object> variableMap = new HashMap<>();
        for (Map.Entry<String, ExpressionExecutor> entry :
                recordStoreCompiledCondition.variableExpressionExecutorMap.entrySet()) {
            variableMap.put(entry.getKey(), entry.getValue().execute(stateEvent));
        }

        deleteConditionParameterMaps.add(variableMap);
        timestamp = stateEvent.getTimestamp();
    }
    if (recordTableHandler != null) {
        recordTableHandler.delete(timestamp, deleteConditionParameterMaps, recordStoreCompiledCondition.
                compiledCondition);
    } else {
        delete(deleteConditionParameterMaps, recordStoreCompiledCondition.compiledCondition);
    }
}
 
Example #9
Source File: Sink.java    From siddhi with Apache License 2.0 5 votes vote down vote up
protected void retryPublish(Object payload) throws ConnectionUnavailableException {
    DynamicOptions dynamicOptions = trpDynamicOptions.get();
    S state = stateHolder.getState();
    try {
        publish(payload, dynamicOptions, state);
        if (throughputTracker != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            throughputTracker.eventIn();
        }
    } finally {
        stateHolder.returnState(state);
    }
}
 
Example #10
Source File: Sink.java    From siddhi with Apache License 2.0 5 votes vote down vote up
private void connectAndPublish(Object payload, DynamicOptions dynamicOptions, S state)
        throws ConnectionUnavailableException {
    connect();
    setConnected(true);
    publish(payload, dynamicOptions, state);
    if (connectionCallback != null) {
        connectionCallback.connectionEstablished();
    }
}
 
Example #11
Source File: Source.java    From siddhi with Apache License 2.0 5 votes vote down vote up
private void retryWithBackoff(ConnectionUnavailableException e) {
    LOG.error(ExceptionUtil.getMessageWithContext(e, siddhiAppContext) +
            " Error while connecting at Source '" + StringUtil.removeCRLFCharacters(type) + "' at '" +
            StringUtil.removeCRLFCharacters(streamDefinition.getId()) + "'. Will retry in '" +
            StringUtil.removeCRLFCharacters(backoffRetryCounter.getTimeInterval()) + "'.", e);
    scheduledExecutorService.schedule(new Runnable() {
        @Override
        public void run() {
            connectWithRetry();
        }
    }, backoffRetryCounter.getTimeIntervalMillis(), TimeUnit.MILLISECONDS);
    backoffRetryCounter.increment();
}
 
Example #12
Source File: InMemorySink.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public void publish(Object payload, DynamicOptions dynamicOptions, State s) throws ConnectionUnavailableException {
    try {
        InMemoryBroker.publish(topicOption.getValue(dynamicOptions), payload);
    } catch (SubscriberUnAvailableException e) {
        onError(payload, dynamicOptions, new ConnectionUnavailableException(e.getMessage(), e));
    }
}
 
Example #13
Source File: Sink.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public final void publish(Object payload) {
    if (mapperLatencyTracker != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
        mapperLatencyTracker.markOut();
    }
    DynamicOptions dynamicOptions = trpDynamicOptions.get();
    if (isConnected()) {
        S state = stateHolder.getState();
        try {
            publish(payload, dynamicOptions, state);
            if (throughputTracker != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                throughputTracker.eventIn();
            }
        } catch (ConnectionUnavailableException e) {
            setConnected(false);
            if (connectionCallback != null) {
                connectionCallback.connectionFailed();
            }
            if (!isTryingToConnect.getAndSet(true)) {
                try {
                    connectAndPublish(payload, dynamicOptions, state);
                    isTryingToConnect.set(false);
                } catch (ConnectionUnavailableException e1) {
                    isTryingToConnect.set(false);
                    onError(payload, dynamicOptions, e);
                }
            } else {
                onError(payload, dynamicOptions, e);
            }
        } finally {
            stateHolder.returnState(state);
        }
    } else if (!isShutdown.get()) {
        onError(payload, dynamicOptions, new ConnectionUnavailableException(
                "Connection unavailable at Sink '" + type + "' at '" + streamDefinition.getId() +
                        "'. Connection retrying is in progress from a different thread"));
    }
}
 
Example #14
Source File: KafkaMultiDCSink.java    From siddhi-io-kafka with Apache License 2.0 5 votes vote down vote up
@Override
public void connect() throws ConnectionUnavailableException {
    Properties props = new Properties();
    props.put("acks", "all");
    props.put("retries", 0);
    props.put("batch.size", 16384);
    props.put("linger.ms", 1);
    props.put("buffer.memory", 33554432);
    props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");

    if (!isBinaryMessage) {
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
    } else {
        props.put("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
    }

    KafkaIOUtils.splitHeaderValues(optionalConfigs, props);

    String[] bootstrapServersList = bootstrapServers.split(",");
    for (int index = 0; index < bootstrapServersList.length; index++) {
        String server = bootstrapServersList[index].trim();
        props.put("bootstrap.servers", server);
        Producer<String, String> producer = new KafkaProducer<>(props);
        producers.add(producer);
        LOG.info("Kafka producer created for Kafka cluster :" + server);
    }
}
 
Example #15
Source File: TestStoreForCacheMiss.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateOrAdd(CompiledCondition updateCondition,
                           List<Map<String, Object>> updateConditionParameterMaps,
                           Map<String, CompiledExpression> updateSetExpressions,
                           List<Map<String, Object>> updateSetParameterMaps,
                           List<Object[]> addingRecords) throws ConnectionUnavailableException {
}
 
Example #16
Source File: LogSink.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public void publish(Object payload, DynamicOptions transportOptions, State s)
        throws ConnectionUnavailableException {
    String message;
    if (payload instanceof Object[]) {
        message = logPrefix + " : " + Arrays.deepToString((Object[]) payload);
    } else {
        message = logPrefix + " : " + payload;
    }
    logMessage(logPriority, message);
}
 
Example #17
Source File: AbstractRecordTable.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public StreamEvent find(CompiledCondition compiledCondition, StateEvent matchingEvent)
        throws ConnectionUnavailableException {
    RecordStoreCompiledCondition recordStoreCompiledCondition =
            ((RecordStoreCompiledCondition) compiledCondition);

    Map<String, Object> findConditionParameterMap = new HashMap<>();
    for (Map.Entry<String, ExpressionExecutor> entry : recordStoreCompiledCondition.variableExpressionExecutorMap
            .entrySet()) {
        findConditionParameterMap.put(entry.getKey(), entry.getValue().execute(matchingEvent));
    }

    Iterator<Object[]> records;
    if (recordTableHandler != null) {
        records = recordTableHandler.find(matchingEvent.getTimestamp(), findConditionParameterMap,
                recordStoreCompiledCondition.compiledCondition);
    } else {
        records = find(findConditionParameterMap, recordStoreCompiledCondition.compiledCondition);
    }
    ComplexEventChunk<StreamEvent> streamEventComplexEventChunk = new ComplexEventChunk<>();
    if (records != null) {
        while (records.hasNext()) {
            Object[] record = records.next();
            StreamEvent streamEvent = storeEventPool.newInstance();
            System.arraycopy(record, 0, streamEvent.getOutputData(), 0, record.length);
            streamEventComplexEventChunk.add(streamEvent);
        }
    }
    return streamEventComplexEventChunk.getFirst();
}
 
Example #18
Source File: AbstractQueryableRecordTable.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public void add(ComplexEventChunk<StreamEvent> addingEventChunk) throws ConnectionUnavailableException {
    if (cacheEnabled) {
        readWriteLock.writeLock().lock();
        try {
            ((CacheTable) cacheTable).addAndTrimUptoMaxSize(addingEventChunk);
            super.add(addingEventChunk);
        } finally {
            readWriteLock.writeLock().unlock();
        }
    } else {
        super.add(addingEventChunk);
    }
}
 
Example #19
Source File: TestStoreForCachePreLoading.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateOrAdd(CompiledCondition updateCondition,
                           List<Map<String, Object>> updateConditionParameterMaps,
                           Map<String, CompiledExpression> updateSetExpressions,
                           List<Map<String, Object>> updateSetParameterMaps,
                           List<Object[]> addingRecords) throws ConnectionUnavailableException {
}
 
Example #20
Source File: RecordTableHandler.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public boolean contains(long timestamp, Map<String, Object> containsConditionParameterMap,
                        CompiledCondition compiledCondition) throws ConnectionUnavailableException {
    S state = stateHolder.getState();
    try {
        return contains(timestamp, containsConditionParameterMap, compiledCondition,
                recordTableHandlerCallback, state);
    } finally {
        stateHolder.returnState(state);
    }
}
 
Example #21
Source File: Table.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public void deleteEvents(ComplexEventChunk<StateEvent> deletingEventChunk, CompiledCondition compiledCondition,
                         int noOfEvents) {
    if (isConnected.get()) {
        try {
            if (latencyTrackerDelete != null &&
                    Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                latencyTrackerDelete.markIn();
            }
            delete(deletingEventChunk, compiledCondition);
            if (throughputTrackerDelete != null &&
                    Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                throughputTrackerDelete.eventsIn(noOfEvents);
            }
        } catch (ConnectionUnavailableException e) {
            isConnected.set(false);
            LOG.error(ExceptionUtil.getMessageWithContext(e, siddhiAppContext) +
                    " Connection unavailable at Table '" + tableDefinition.getId() +
                    "', will retry connection immediately.", e);
            connectWithRetry();
            deleteEvents(deletingEventChunk, compiledCondition, noOfEvents);
        } finally {
            if (latencyTrackerDelete != null &&
                    Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                latencyTrackerDelete.markOut();
            }
        }
    } else if (isTryingToConnect.get()) {
        LOG.warn("Error on '" + siddhiAppContext.getName() + "' while performing delete for events '" +
                deletingEventChunk + "', operation busy waiting at Table '" + tableDefinition.getId() +
                "' as its trying to reconnect!");
        waitWhileConnect();
        LOG.info("SiddhiApp '" + siddhiAppContext.getName() + "' table '" + tableDefinition.getId() +
                "' has become available for delete operation for events '" + deletingEventChunk + "'");
        deleteEvents(deletingEventChunk, compiledCondition, noOfEvents);
    } else {
        connectWithRetry();
        deleteEvents(deletingEventChunk, compiledCondition, noOfEvents);
    }
}
 
Example #22
Source File: TestFailingInMemorySource.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public void connect(ConnectionCallback connectionCallback, State state) throws ConnectionUnavailableException {
    this.connectionCallback = connectionCallback;
    if (fail) {
        numberOfErrorOccurred++;
        throw new ConnectionUnavailableException("Connection failed!");
    }
    super.connect(connectionCallback, state);
}
 
Example #23
Source File: Table.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public void updateEvents(ComplexEventChunk<StateEvent> updatingEventChunk,
                         CompiledCondition compiledCondition,
                         CompiledUpdateSet compiledUpdateSet, int noOfEvents) {
    if (isConnected.get()) {
        try {
            if (latencyTrackerUpdate != null &&
                    Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                latencyTrackerUpdate.markIn();
            }
            update(updatingEventChunk, compiledCondition, compiledUpdateSet);
            if (throughputTrackerUpdate != null &&
                    Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                throughputTrackerUpdate.eventsIn(noOfEvents);
            }
        } catch (ConnectionUnavailableException e) {
            isConnected.set(false);
            LOG.error(ExceptionUtil.getMessageWithContext(e, siddhiAppContext) +
                    " Connection unavailable at Table '" + tableDefinition.getId() +
                    "', will retry connection immediately.", e);
            connectWithRetry();
            updateEvents(updatingEventChunk, compiledCondition, compiledUpdateSet, noOfEvents);
        } finally {
            if (latencyTrackerUpdate != null &&
                    Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                latencyTrackerUpdate.markOut();
            }
        }
    } else if (isTryingToConnect.get()) {
        LOG.warn("Error on '" + siddhiAppContext.getName() + "' while performing update for events '" +
                updatingEventChunk + "', operation busy waiting at Table '" + tableDefinition.getId() +
                "' as its trying to reconnect!");
        waitWhileConnect();
        LOG.info("SiddhiApp '" + siddhiAppContext.getName() + "' table '" + tableDefinition.getId() +
                "' has become available for update operation for events '" + updatingEventChunk + "'");
        updateEvents(updatingEventChunk, compiledCondition, compiledUpdateSet, noOfEvents);
    } else {
        connectWithRetry();
        updateEvents(updatingEventChunk, compiledCondition, compiledUpdateSet, noOfEvents);
    }
}
 
Example #24
Source File: IncrementalAggregateCompileCondition.java    From siddhi with Apache License 2.0 5 votes vote down vote up
private StreamEvent query(Table tableForPerDuration, StateEvent matchingEvent, CompiledCondition compiledCondition,
                          CompiledSelection compiledSelection, Attribute[] outputAttributes) {
    if (tableForPerDuration.getIsConnected()) {
        try {
            return ((QueryableProcessor) tableForPerDuration)
                    .query(matchingEvent, compiledCondition, compiledSelection, outputAttributes);
        } catch (ConnectionUnavailableException e) {
            // On-demand query does not have retry logic and retry called manually
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unable to query table '" + tableForPerDuration.getTableDefinition().getId() + "', "
                        + "as the datasource is unavailable.");
            }
            if (!isOnDemandQuery) {
                tableForPerDuration.setIsConnectedToFalse();
                tableForPerDuration.connectWithRetry();
                return query(tableForPerDuration, matchingEvent, compiledCondition, compiledSelection,
                        outputAttributes);
            }
            throw new SiddhiAppRuntimeException(e.getMessage(), e);
        }
    } else if (tableForPerDuration.getIsTryingToConnect()) {
        LOG.warn("Error on '" + aggregationName + "' while performing query for event '" + matchingEvent +
                "', operation busy waiting at Table '" + tableForPerDuration.getTableDefinition().getId() +
                "' as its trying to reconnect!");
        tableForPerDuration.waitWhileConnect();
        LOG.info("Aggregation '" + aggregationName + "' table '" +
                tableForPerDuration.getTableDefinition().getId() + "' has become available for query for " +
                "matching event '" + matchingEvent + "'");
        return query(tableForPerDuration, matchingEvent, compiledCondition, compiledSelection,
                outputAttributes);
    } else {
        tableForPerDuration.connectWithRetry();
        return query(tableForPerDuration, matchingEvent, compiledCondition, compiledSelection,
                outputAttributes);

    }
}
 
Example #25
Source File: TestFailingInMemorySink.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public void publish(Object payload, DynamicOptions dynamicOptions, State state)
        throws ConnectionUnavailableException {
    if (fail || failOnce || publishAlwaysFail) {
        failOnce = false;
        numberOfErrorOccurred++;
        throw new ConnectionUnavailableException("Connection unavailable during publishing");
    }
    super.publish(payload, dynamicOptions, state);
}
 
Example #26
Source File: TestFailingInMemorySink.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public void connect() throws ConnectionUnavailableException {
    if (fail || failOnce) {
        failOnce = false;
        numberOfErrorOccurred++;
        throw new ConnectionUnavailableException("Connection unavailable during connection");
    }
    super.connect();
}
 
Example #27
Source File: TestOptionInMemorySink.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public void publish(Object payload, DynamicOptions dynamicOptions, State s) throws ConnectionUnavailableException {
    try {
        InMemoryBroker.publish(topicPrefix + "-" + topicOption.getValue(dynamicOptions), payload);
    } catch (SubscriberUnAvailableException e) {
        log.error(e.getMessage(), e);
    }
}
 
Example #28
Source File: RecordTableHandler.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public void delete(long timestamp, List<Map<String, Object>> deleteConditionParameterMaps,
                   CompiledCondition compiledCondition) throws ConnectionUnavailableException {
    S state = stateHolder.getState();
    try {
        delete(timestamp, deleteConditionParameterMaps, compiledCondition, recordTableHandlerCallback, state);
    } finally {
        stateHolder.returnState(state);
    }
}
 
Example #29
Source File: RecordTableHandler.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public void add(long timestamp, List<Object[]> records) throws ConnectionUnavailableException {
    S state = stateHolder.getState();
    try {
        add(timestamp, records, recordTableHandlerCallback, state);
    } finally {
        stateHolder.returnState(state);
    }
}
 
Example #30
Source File: RecordTableHandlerCallback.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public Iterator<Object[]> query(Map<String, Object> parameterMap, CompiledCondition compiledCondition,
                                CompiledSelection compiledSelection, Attribute[] outputAttributes)
        throws ConnectionUnavailableException {
    if (abstractRecordTable instanceof AbstractQueryableRecordTable) {
        return ((AbstractQueryableRecordTable) abstractRecordTable).query(parameterMap, compiledCondition,
                compiledSelection, outputAttributes);
    } else {
        log.error("Record Table " + this.abstractRecordTable.getTableDefinition().getId() +
                " used is not a Queryable Record Table.");
        return null;
    }
}