Search in sources :

Example 1 with StorageFilter

use of cz.o2.proxima.storage.StorageFilter in project proxima-platform by O2-Czech-Republic.

the class ReplicationController method runTransform.

private void runTransform(String name, TransformationDescriptor transform, DirectAttributeFamilyDescriptor family) {
    final StorageFilter filter = transform.getFilter();
    final String consumer = transform.getConsumerNameFactory().apply();
    final CommitLogReader reader = family.getCommitLogReader().orElseThrow(() -> new IllegalStateException("Unable to get reader for family " + family.getDesc().getName() + "."));
    final TransformationObserver observer;
    if (transform.getTransformation().isContextual()) {
        DirectElementWiseTransform transformation = transform.getTransformation().as(DirectElementWiseTransform.class);
        observer = contextualObserver(dataOperator, name, transformation, transform.getOutputTransactionMode() == OutputTransactionMode.ENABLED, filter);
    } else {
        ElementWiseTransformation transformation = transform.getTransformation().asElementWiseTransform();
        observer = nonContextualObserver(dataOperator, name, transformation, transform.getOutputTransactionMode() == OutputTransactionMode.ENABLED, filter);
    }
    startTransformationObserverUsing(consumer, reader, observer);
    log.info("Started transformer {} reading from {} using {}", consumer, reader.getUri(), transform.getTransformation().getClass());
}
Also used : ElementWiseTransformation(cz.o2.proxima.transform.ElementWiseTransformation) StorageFilter(cz.o2.proxima.storage.StorageFilter) DirectElementWiseTransform(cz.o2.proxima.direct.transform.DirectElementWiseTransform) CommitLogReader(cz.o2.proxima.direct.commitlog.CommitLogReader) TransformationObserver(cz.o2.proxima.direct.transform.TransformationObserver)

Example 2 with StorageFilter

use of cz.o2.proxima.storage.StorageFilter in project proxima-platform by O2-Czech-Republic.

the class ReplicationController method consumeLog.

private void consumeLog(DirectAttributeFamilyDescriptor primaryFamily, DirectAttributeFamilyDescriptor replicaFamily) {
    final CommitLogReader commitLog = primaryFamily.getCommitLogReader().orElseThrow(() -> new IllegalStateException(String.format("Failed to find commit-log reader in family %s.", primaryFamily)));
    final AttributeWriterBase writer = replicaFamily.getWriter().orElseThrow(() -> new IllegalStateException(String.format("Unable to get writer for family %s.", replicaFamily.getDesc().getName())));
    final StorageFilter filter = replicaFamily.getDesc().getFilter();
    final Set<AttributeDescriptor<?>> allowedAttributes = new HashSet<>(replicaFamily.getAttributes());
    final String name = replicaFamily.getDesc().getReplicationConsumerNameFactory().apply();
    log.info("Using consumer name {} to replicate family {}", name, replicaFamily.getDesc().getName());
    registerWriterTo(name, commitLog, allowedAttributes, filter, writer);
    log.info("Started consumer {} consuming from log {} with URI {} into {} attributes {}", name, commitLog, commitLog.getUri(), writer.getUri(), allowedAttributes);
}
Also used : StorageFilter(cz.o2.proxima.storage.StorageFilter) CommitLogReader(cz.o2.proxima.direct.commitlog.CommitLogReader) AttributeWriterBase(cz.o2.proxima.direct.core.AttributeWriterBase) AttributeDescriptor(cz.o2.proxima.repository.AttributeDescriptor) HashSet(java.util.HashSet)

Aggregations

CommitLogReader (cz.o2.proxima.direct.commitlog.CommitLogReader)2 StorageFilter (cz.o2.proxima.storage.StorageFilter)2 AttributeWriterBase (cz.o2.proxima.direct.core.AttributeWriterBase)1 DirectElementWiseTransform (cz.o2.proxima.direct.transform.DirectElementWiseTransform)1 TransformationObserver (cz.o2.proxima.direct.transform.TransformationObserver)1 AttributeDescriptor (cz.o2.proxima.repository.AttributeDescriptor)1 ElementWiseTransformation (cz.o2.proxima.transform.ElementWiseTransformation)1 HashSet (java.util.HashSet)1