io.datarouter.gcp.spanner.SpannerClientNodeFactory 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.gcp.spanner;
import javax.inject.Inject;
import javax.inject.Singleton;
import io.datarouter.gcp.spanner.field.SpannerFieldCodecs;
import io.datarouter.gcp.spanner.node.SpannerBlobNode;
import io.datarouter.gcp.spanner.node.SpannerNode;
import io.datarouter.gcp.spanner.node.SpannerTallyNode;
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.serialize.fielder.DatabeanFielder;
import io.datarouter.opencensus.adapter.physical.PhysicalIndexedSortedMapStorageOpencensusAdapter;
import io.datarouter.storage.client.imp.BlobClientNodeFactory;
import io.datarouter.storage.client.imp.DatabeanClientNodeFactory;
import io.datarouter.storage.client.imp.TallyClientNodeFactory;
import io.datarouter.storage.file.DatabaseBlob;
import io.datarouter.storage.file.DatabaseBlob.DatabaseBlobFielder;
import io.datarouter.storage.file.DatabaseBlobKey;
import io.datarouter.storage.node.NodeParams;
import io.datarouter.storage.node.adapter.NodeAdapters;
import io.datarouter.storage.node.adapter.availability.PhysicalIndexedSortedMapStorageAvailabilityAdapterFactory;
import io.datarouter.storage.node.adapter.callsite.physical.PhysicalIndexedSortedMapStorageCallsiteAdapter;
import io.datarouter.storage.node.adapter.counter.physical.PhysicalIndexedSortedMapStorageCounterAdapter;
import io.datarouter.storage.node.adapter.sanitization.physical.PhysicalIndexedSortedMapStorageSanitizationAdapter;
import io.datarouter.storage.node.adapter.trace.physical.PhysicalIndexedSortedMapStorageTraceAdapter;
import io.datarouter.storage.node.entity.EntityNodeParams;
import io.datarouter.storage.node.op.raw.BlobStorage.PhysicalBlobStorageNode;
import io.datarouter.storage.node.op.raw.TallyStorage.PhysicalTallyStorageNode;
import io.datarouter.storage.node.type.index.ManagedNodesHolder;
import io.datarouter.storage.node.type.physical.PhysicalNode;
import io.datarouter.storage.tally.Tally;
import io.datarouter.storage.tally.Tally.TallyFielder;
import io.datarouter.storage.tally.TallyKey;
@Singleton
public class SpannerClientNodeFactory
implements BlobClientNodeFactory, DatabeanClientNodeFactory, TallyClientNodeFactory{
@Inject
private SpannerClientType spannerClientType;
@Inject
private ManagedNodesHolder managedNodesHolder;
@Inject
private SpannerClientManager spannerClientManager;
@Inject
private SpannerFieldCodecs fieldCodecs;
@Inject
private PhysicalIndexedSortedMapStorageAvailabilityAdapterFactory
physicalIndexedSortedMapStorageAvailabilityAdapterFactory;
@Inject
private NodeAdapters nodeAdapters;
/*---------------- DatabeanClientNodeFactory ------------------*/
@Override
public ,
E extends Entity,
PK extends EntityPrimaryKey,
D extends Databean,
F extends DatabeanFielder>
PhysicalNode createDatabeanNode(
EntityNodeParams entityNodeParams,
NodeParams nodeParams){
var node = new SpannerNode<>(
nodeParams,
spannerClientType,
managedNodesHolder,
spannerClientManager,
fieldCodecs);
return new PhysicalIndexedSortedMapStorageCallsiteAdapter<>(
new PhysicalIndexedSortedMapStorageSanitizationAdapter<>(
physicalIndexedSortedMapStorageAvailabilityAdapterFactory.create(
new PhysicalIndexedSortedMapStorageCounterAdapter<>(
new PhysicalIndexedSortedMapStorageTraceAdapter<>(
//custom OpencensusAdapter goes inside TraceAdapter
new PhysicalIndexedSortedMapStorageOpencensusAdapter<>(node))))));
}
@Override
public PhysicalTallyStorageNode createTallyNode(NodeParams nodeParams){
var node = new SpannerTallyNode(
nodeParams,
spannerClientType,
spannerClientManager,
fieldCodecs);
return nodeAdapters.wrapTallyNode(node);
}
@Override
public PhysicalBlobStorageNode createBlobNode(
NodeParams nodeParams){
var node = new SpannerBlobNode(
nodeParams,
spannerClientType,
spannerClientManager,
fieldCodecs);
return nodeAdapters.wrapBlobNode(node);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy