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

io.datarouter.opencensus.adapter.mixin.IndexedStorageOpencensusAdapterMixin 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.opencensus.adapter.mixin;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

import io.datarouter.model.databean.Databean;
import io.datarouter.model.index.IndexEntry;
import io.datarouter.model.key.primary.PrimaryKey;
import io.datarouter.model.key.unique.UniqueKey;
import io.datarouter.model.serialize.fielder.DatabeanFielder;
import io.datarouter.opencensus.adapter.OpencensusAdapter;
import io.datarouter.scanner.Scanner;
import io.datarouter.storage.config.Config;
import io.datarouter.storage.node.op.raw.IndexedStorage;
import io.datarouter.storage.node.op.raw.IndexedStorage.IndexedStorageNode;
import io.datarouter.storage.node.type.index.ManagedNode;
import io.datarouter.storage.serialize.fieldcache.IndexEntryFieldInfo;
import io.datarouter.util.tuple.Range;
import io.opencensus.common.Scope;

public interface IndexedStorageOpencensusAdapterMixin<
		PK extends PrimaryKey,
		D extends Databean,
		F extends DatabeanFielder,
		N extends IndexedStorageNode>
extends IndexedStorage, OpencensusAdapter{

	N getBackingNode();

	@Override
	default void deleteUnique(UniqueKey uniqueKey, Config config){
		Optional span = startSpan();
		try{
			getBackingNode().deleteUnique(uniqueKey, config);
		}finally{
			span.ifPresent(Scope::close);
		}
	}

	@Override
	default void deleteMultiUnique(Collection> uniqueKeys, Config config){
		Optional span = startSpan();
		try{
			getBackingNode().deleteMultiUnique(uniqueKeys, config);
		}finally{
			span.ifPresent(Scope::close);
		}
	}

	@Override
	default ,
			IE extends IndexEntry,
			IF extends DatabeanFielder> void deleteByIndex(Collection keys, Config config,
			IndexEntryFieldInfo indexEntryFieldInfo){
		Optional span = startSpan();
		try{
			getBackingNode().deleteByIndex(keys, config, indexEntryFieldInfo);
		}finally{
			span.ifPresent(Scope::close);
		}
	}

	@Override
	default D lookupUnique(UniqueKey uniqueKey, Config config){
		Optional span = startSpan();
		try{
			return getBackingNode().lookupUnique(uniqueKey, config);
		}finally{
			span.ifPresent(Scope::close);
		}
	}

	@Override
	default List lookupMultiUnique(Collection> uniqueKeys, Config config){
		Optional span = startSpan();
		try{
			return getBackingNode().lookupMultiUnique(uniqueKeys, config);
		}finally{
			span.ifPresent(Scope::close);
		}
	}

	@Override
	default ,
			IE extends IndexEntry,
			IF extends DatabeanFielder>
	List getMultiFromIndex(Collection keys, Config config, IndexEntryFieldInfo indexEntryFieldInfo){
		Optional span = startSpan();
		try{
			return getBackingNode().getMultiFromIndex(keys, config, indexEntryFieldInfo);
		}finally{
			span.ifPresent(Scope::close);
		}
	}

	@Override
	default ,
			IE extends IndexEntry,
			IF extends DatabeanFielder>
	List getMultiByIndex(Collection keys, Config config, IndexEntryFieldInfo indexEntryFieldInfo){
		Optional span = startSpan();
		try{
			return getBackingNode().getMultiByIndex(keys, config, indexEntryFieldInfo);
		}finally{
			span.ifPresent(Scope::close);
		}
	}

	@Override
	default ,
			IE extends IndexEntry,
			IF extends DatabeanFielder>
	Scanner scanRangesIndex(IndexEntryFieldInfo indexEntryFieldInfo, Collection> ranges,
			Config config){
		Optional span = startSpan();
		try{
			return getBackingNode().scanRangesIndex(indexEntryFieldInfo, ranges, config);
		}finally{
			span.ifPresent(Scope::close);
		}
	}

	@Override
	default ,
			IE extends IndexEntry,
			IF extends DatabeanFielder>
	Scanner scanRangesByIndex(IndexEntryFieldInfo indexEntryFieldInfo, Collection> ranges,
			Config config){
		Optional span = startSpan();
		try{
			return getBackingNode().scanRangesByIndex(indexEntryFieldInfo, ranges, config);
		}finally{
			span.ifPresent(Scope::close);
		}
	}

	@Override
	default ,
			IE extends IndexEntry,
			IF extends DatabeanFielder>
	Scanner scanRangesIndexKeys(IndexEntryFieldInfo indexEntryFieldInfo, Collection> ranges,
			Config config){
		Optional span = startSpan();
		try{
			return getBackingNode().scanRangesIndexKeys(indexEntryFieldInfo, ranges, config);
		}finally{
			span.ifPresent(Scope::close);
		}
	}

	@Override
	default ,
			IE extends IndexEntry,
			IF extends DatabeanFielder,
			MN extends ManagedNode>
	MN registerManaged(MN managedNode){
		return getBackingNode().registerManaged(managedNode);
	}


	@Override
	default List> getManagedNodes(){
		return getBackingNode().getManagedNodes();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy