use of org.infinispan.util.KeyValuePair in project infinispan by infinispan.
the class CheckAddressTask method getRequestMediaTypes.
private static KeyValuePair<MediaType, MediaType> getRequestMediaTypes(HotRodHeader header, Configuration configuration) {
MediaType keyRequestType = header == null ? APPLICATION_UNKNOWN : header.getKeyMediaType();
MediaType valueRequestType = header == null ? APPLICATION_UNKNOWN : header.getValueMediaType();
if (header != null && HotRodVersion.HOTROD_28.isOlder(header.version)) {
// Pre-2.8 clients always send protobuf payload to the metadata cache
if (header.cacheName.equals(PROTOBUF_METADATA_CACHE_NAME)) {
keyRequestType = APPLICATION_PROTOSTREAM;
valueRequestType = APPLICATION_PROTOSTREAM;
} else {
// Pre-2.8 clients always sent query encoded as protobuf unless object store is used.
if (header.op == HotRodOperation.QUERY) {
boolean objectStorage = APPLICATION_OBJECT.match(configuration.encoding().valueDataType().mediaType());
keyRequestType = objectStorage ? APPLICATION_JBOSS_MARSHALLING : APPLICATION_PROTOSTREAM;
valueRequestType = objectStorage ? APPLICATION_JBOSS_MARSHALLING : APPLICATION_PROTOSTREAM;
}
}
}
return new KeyValuePair<>(keyRequestType, valueRequestType);
}
use of org.infinispan.util.KeyValuePair in project infinispan by infinispan.
the class JpaStore method publishKeys.
@Override
public Flowable<K> publishKeys(Predicate<? super K> filter) {
return Flowable.using(() -> {
EntityManager emStream = emf.createEntityManager();
Session session = emStream.unwrap(Session.class);
Criteria criteria = session.createCriteria(configuration.entityClass()).setProjection(Projections.id()).setReadOnly(true);
if (setFetchSizeMinInteger) {
criteria.setFetchSize(Integer.MIN_VALUE);
}
ScrollableResults results = criteria.scroll(ScrollMode.FORWARD_ONLY);
return new KeyValuePair<>(emStream, results);
}, kvp -> {
ScrollableResults results = kvp.getValue();
return Flowable.fromIterable(() -> new ScrollableResultsIterator(results, filter));
}, kvp -> {
try {
kvp.getValue().close();
} finally {
kvp.getKey().close();
}
});
}
use of org.infinispan.util.KeyValuePair in project infinispan by infinispan.
the class AbstractHotRodClusterEventsTest method testConversionInCluster.
public void testConversionInCluster(Method m) {
HotRodClient client1 = clients().get(0);
HotRodClient client2 = clients().get(1);
EventLogListener listener1 = new EventLogListener();
Optional<KeyValuePair<String, List<byte[]>>> converterFactory = Optional.of(new KeyValuePair<String, List<byte[]>>("accepted-keyvalue-converter-factory", Collections.emptyList()));
final byte[] key1 = k(m, "k1-");
withClusterClientListener(client1, listener1, Optional.empty(), converterFactory, key1, false, () -> {
byte[] value = v(m);
byte[] key99 = k(m, "k-99");
client2.put(key99, 0, 0, v(m));
listener1.expectSingleCustomEvent(anyCache(), addLengthPrefix(key99));
client2.put(key1, 0, 0, v(m));
listener1.expectSingleCustomEvent(anyCache(), addLengthPrefix(key1, value));
client2.remove(key99);
listener1.expectSingleCustomEvent(anyCache(), addLengthPrefix(key99));
client2.remove(key1);
listener1.expectSingleCustomEvent(anyCache(), addLengthPrefix(key1));
});
}
use of org.infinispan.util.KeyValuePair in project infinispan by infinispan.
the class AbstractHotRodClusterEventsTest method testFilteringInCluster.
public void testFilteringInCluster(Method m) {
HotRodClient client1 = clients().get(0);
HotRodClient client2 = clients().get(1);
EventLogListener listener1 = new EventLogListener();
Optional<KeyValuePair<String, List<byte[]>>> filterFactory = Optional.of(new KeyValuePair<String, List<byte[]>>("accepted-key-filter-factory", Collections.emptyList()));
byte[] key1 = k(m, "k1-");
withClusterClientListener(client1, listener1, filterFactory, Optional.empty(), key1, false, () -> {
client2.put(k(m, "k-99"), 0, 0, v(m));
listener1.expectNoEvents(Optional.empty());
client2.remove(k(m, "k-99"));
listener1.expectNoEvents(Optional.empty());
client2.put(key1, 0, 0, v(m));
listener1.expectOnlyCreatedEvent(anyCache(), key1);
client1.remove(key1);
listener1.expectOnlyRemovedEvent(anyCache(), key1);
});
}
use of org.infinispan.util.KeyValuePair in project infinispan by infinispan.
the class AbstractHotRodClusterEventsTest method testParameterBasedFilteringInCluster.
public void testParameterBasedFilteringInCluster(Method m) {
HotRodClient client1 = clients().get(0);
HotRodClient client2 = clients().get(1);
EventLogListener listener1 = new EventLogListener();
byte[] dynamicAcceptedKey = new byte[] { 4, 5, 6 };
Optional<KeyValuePair<String, List<byte[]>>> filterFactory = Optional.of(new KeyValuePair<>("accepted-key-filter-factory", Collections.singletonList(dynamicAcceptedKey)));
withClusterClientListener(client1, listener1, filterFactory, Optional.empty(), null, false, () -> {
byte[] key1 = k(m, "k1-");
client2.put(k(m, "k-99"), 0, 0, v(m));
listener1.expectNoEvents(Optional.empty());
client2.remove(k(m, "k-99"));
listener1.expectNoEvents(Optional.empty());
client2.put(key1, 0, 0, v(m));
listener1.expectNoEvents(Optional.empty());
client2.put(dynamicAcceptedKey, 0, 0, v(m));
listener1.expectOnlyCreatedEvent(anyCache(), dynamicAcceptedKey);
client1.remove(dynamicAcceptedKey);
listener1.expectOnlyRemovedEvent(anyCache(), dynamicAcceptedKey);
});
}
Aggregations