
io.datarouter.client.redis.RedisClientNodeFactory Maven / Gradle / Ivy
/**
* Copyright © 2009 HotPads ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.datarouter.client.redis;
import java.util.List;
import java.util.function.UnaryOperator;
import javax.inject.Inject;
import javax.inject.Singleton;
import io.datarouter.client.redis.client.RedisClientManager;
import io.datarouter.client.redis.config.RedisExecutors.RedisBatchOpExecutor;
import io.datarouter.client.redis.node.RedisNode;
import io.datarouter.model.databean.Databean;
import io.datarouter.model.entity.Entity;
import io.datarouter.model.key.entity.EntityKey;
import io.datarouter.model.key.primary.EntityPrimaryKey;
import io.datarouter.model.key.primary.PrimaryKey;
import io.datarouter.model.serialize.fielder.DatabeanFielder;
import io.datarouter.storage.client.imp.BaseClientNodeFactory;
import io.datarouter.storage.client.imp.TallyClientNodeFactory;
import io.datarouter.storage.client.imp.WrappedNodeFactory;
import io.datarouter.storage.node.NodeParams;
import io.datarouter.storage.node.adapter.availability.PhysicalMapStorageAvailabilityAdapterFactory;
import io.datarouter.storage.node.adapter.callsite.physical.PhysicalMapStorageCallsiteAdapter;
import io.datarouter.storage.node.adapter.counter.physical.PhysicalMapStorageCounterAdapter;
import io.datarouter.storage.node.adapter.counter.physical.PhysicalTallyStorageCounterAdapter;
import io.datarouter.storage.node.adapter.sanitization.physical.PhysicalTallyStorageSanitizationAdapter;
import io.datarouter.storage.node.adapter.trace.physical.PhysicalMapStorageTraceAdapter;
import io.datarouter.storage.node.adapter.trace.physical.PhysicalTallyStorageTraceAdapter;
import io.datarouter.storage.node.entity.EntityNodeParams;
import io.datarouter.storage.node.op.raw.MapStorage.PhysicalMapStorageNode;
import io.datarouter.storage.node.type.physical.PhysicalNode;
@Singleton
public class RedisClientNodeFactory extends BaseClientNodeFactory implements TallyClientNodeFactory{
@Inject
private PhysicalMapStorageAvailabilityAdapterFactory physicalMapStorageAvailabilityAdapterFactory;
@Inject
private RedisClientType redisClientType;
@Inject
private RedisClientManager redisClientManager;
@Inject
private RedisNodeFactory redisNodeFactory;
@Inject
private RedisBatchOpExecutor executor;
public class RedisWrappedNodeFactory<
EK extends EntityKey,
E extends Entity,
PK extends EntityPrimaryKey,
D extends Databean,
F extends DatabeanFielder>
extends WrappedNodeFactory>{
@Override
public PhysicalMapStorageNode createNode(
EntityNodeParams entityNodeParams,
NodeParams nodeParams){
return new RedisNode<>(nodeParams, redisClientType, redisClientManager, executor);
}
@Override
public List>> getAdapters(){
return List.of(
PhysicalMapStorageCounterAdapter::new,
PhysicalMapStorageTraceAdapter::new,
physicalMapStorageAvailabilityAdapterFactory::create,
PhysicalMapStorageCallsiteAdapter::new);
}
}
@Override
public ,
E extends Entity,
PK extends EntityPrimaryKey,
D extends Databean,
F extends DatabeanFielder>
WrappedNodeFactory> makeWrappedNodeFactory(){
return new RedisWrappedNodeFactory<>();
}
@Override
public ,
D extends Databean,
F extends DatabeanFielder>
PhysicalNode createTallyNode(NodeParams nodeParams){
var node = redisNodeFactory.createTallyNode(nodeParams);
return new PhysicalTallyStorageTraceAdapter<>(
new PhysicalTallyStorageCounterAdapter<>(
new PhysicalTallyStorageSanitizationAdapter<>(node)));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy