All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.datarouter.aws.memcached.client.nodefactory.AwsMemcachedClientNodeFactory Maven / Gradle / Ivy

There is a newer version: 0.0.126
Show newest version
/*
 * 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.aws.memcached.client.nodefactory;

import java.util.List;
import java.util.function.UnaryOperator;

import javax.inject.Inject;
import javax.inject.Singleton;

import io.datarouter.aws.memcached.AwsMemcachedClientType;
import io.datarouter.aws.memcached.client.AwsMemcachedClientManager;
import io.datarouter.client.memcached.node.MemcachedMapStorageNode;
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.BlobClientNodeFactory;
import io.datarouter.storage.client.imp.TallyClientNodeFactory;
import io.datarouter.storage.client.imp.WrappedNodeFactory;
import io.datarouter.storage.file.Pathbean;
import io.datarouter.storage.file.Pathbean.PathbeanFielder;
import io.datarouter.storage.file.PathbeanKey;
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.trace.physical.PhysicalMapStorageTraceAdapter;
import io.datarouter.storage.node.entity.EntityNodeParams;
import io.datarouter.storage.node.op.raw.BlobStorage.PhysicalBlobStorageNode;
import io.datarouter.storage.node.op.raw.MapStorage.PhysicalMapStorageNode;
import io.datarouter.storage.node.type.physical.PhysicalNode;
import io.datarouter.web.config.service.ServiceName;

@Singleton
public class AwsMemcachedClientNodeFactory
extends BaseClientNodeFactory
implements BlobClientNodeFactory, TallyClientNodeFactory{

	private final PhysicalMapStorageAvailabilityAdapterFactory physicalMapStorageAvailabilityAdapterFactory;
	private final AwsMemcachedClientType awsMemcachedClientType;
	private final ServiceName serviceName;
	private final AwsMemcachedClientManager awsMemcachedClientManager;
	private final AwsMemcachedNodeFactory awsMemcachedNodeFactory;

	@Inject
	public AwsMemcachedClientNodeFactory(
			PhysicalMapStorageAvailabilityAdapterFactory physicalMapStorageAvailabilityAdapterFactory,
			AwsMemcachedClientType awsMemcachedClientType,
			AwsMemcachedClientManager awsMemcachedClientManager,
			ServiceName serviceName,
			AwsMemcachedNodeFactory awsMemcachedNodeFactory){
		this.physicalMapStorageAvailabilityAdapterFactory = physicalMapStorageAvailabilityAdapterFactory;
		this.awsMemcachedClientType = awsMemcachedClientType;
		this.serviceName = serviceName;
		this.awsMemcachedClientManager = awsMemcachedClientManager;
		this.awsMemcachedNodeFactory = awsMemcachedNodeFactory;
	}

	/*------------- WrappedNodeFactory ------------*/

	@Override
	public ,
			E extends Entity,
			PK extends EntityPrimaryKey,
			D extends Databean,
			F extends DatabeanFielder>
	WrappedNodeFactory> makeWrappedNodeFactory(){
		return new MemcachedWrappedNodeFactory<>();
	}

	public class MemcachedWrappedNodeFactory<
			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 MemcachedMapStorageNode<>(
					nodeParams,
					awsMemcachedClientType,
					serviceName,
					awsMemcachedClientManager);
		}

		@Override
		public List>> getAdapters(){
			return List.of(
					PhysicalMapStorageCounterAdapter::new,
					PhysicalMapStorageTraceAdapter::new,
					physicalMapStorageAvailabilityAdapterFactory::create,
					PhysicalMapStorageCallsiteAdapter::new);
		}

	}

	/*---------------- BlobClientNodeFactory ------------------*/

	@Override
	public PhysicalBlobStorageNode createBlobNode(NodeParams nodeParams){
		return awsMemcachedNodeFactory.createBlobNode(nodeParams);
	}

	/*---------------- TallyClientNodeFactory ------------------*/

	@Override
	public ,
			D extends Databean,
			F extends DatabeanFielder>
	PhysicalNode createTallyNode(NodeParams nodeParams){
		return awsMemcachedNodeFactory.createTallyNode(nodeParams);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy