Class Fetch<I,E>
- Type Parameters:
I- the type of the identifier of messagesE- the type of the data elements appended into message chunks
The Fetch class offers several constructors, which depending on what the user has already defined, will make it easy to use.
If you are using a channel factory to set up your loading, and have relatively few stores /
topics, the Fetch(IStoreMessageChannelFactory) constructor is the way to go. If you
want to fetch only from some stores, use the Fetch(IStoreMessageChannelFactory, Collection) constructor.
If you want to use a publisher which is different from the default publisher of your channel
(i.e. TuplePublisher for most of the sources) you can use the Fetch(IStoreMessageChannelFactory, Collection, Map) constructor.
If you just have a ITransactionalWriter (that you may have retrieved from the
datastore using myDatastore.getTransactionManager() method), use the Fetch(ITransactionalWriter, List) constructor. To fetch data only from some stores, use
the Fetch(ITransactionalWriter, List, List) constructor.
- Author:
- ActiveViam
-
Constructor Summary
ConstructorsConstructorDescriptionFetch(ITransactionalWriter transactionalWriter, List<? extends IMessageChannel<I, E>> channels) Creates a fetch operation into the given list of channels.Fetch(ITransactionalWriter transactionalWriter, List<? extends IMessageChannel<I, E>> channels, List<String> stores) Creates a fetch operation into the given list of channels.Fetch(IStoreMessageChannelFactory<I, E> channelFactory) Fetches of all the stores, mapped automatically to the source topics that have the same name as the store.Fetch(IStoreMessageChannelFactory<I, E> channelFactory, Collection<String> stores) Fetches of a selection of stores, mapped automatically to the source topics that have the same name as the store.Fetch(IStoreMessageChannelFactory<I, E> channelFactory, Collection<String> stores, Map<String, ITuplePublisher<I>> tupleMapping) Fetches of a selection of stores, mapped automatically to the source topics that have the same name as the store.Fetch(IStoreMessageChannelFactory<I, E> channelFactory, Map<String, String> mapping, Map<String, ITuplePublisher<I>> tupleMapping) Fetches a selection of topics into a selection of stores, with respect to the given topic/store mapping. -
Method Summary
Modifier and TypeMethodDescriptiondefaultMapping(Collection<String> stores) Creates a mapping between stores and topic, with stores names equals to the topic names.Fetches data into theIEpoch.MASTER_BRANCH_NAMEbranch.Fetches data in the specifiedbranchbranch.Main fetching method.
-
Constructor Details
-
Fetch
public Fetch(ITransactionalWriter transactionalWriter, List<? extends IMessageChannel<I, E>> channels) Creates a fetch operation into the given list of channels. This will start the transaction on all stores.- Parameters:
transactionalWriter- transactional writer (must also be a transaction manager)channels- the list of channels to fetch the data from
-
Fetch
public Fetch(ITransactionalWriter transactionalWriter, List<? extends IMessageChannel<I, E>> channels, @Nullable List<String> stores) Creates a fetch operation into the given list of channels.- Parameters:
transactionalWriter- transactional writer (must also be a transaction manager)channels- the list of channels to fetch the data fromstores- stores on which the transaction should be started, null means all stores
-
Fetch
Fetches of all the stores, mapped automatically to the source topics that have the same name as the store.- Parameters:
channelFactory- the channel factory of the source to fetch the data from
-
Fetch
Fetches of a selection of stores, mapped automatically to the source topics that have the same name as the store.- Parameters:
channelFactory- the channel factory of the source to fetch the data fromstores- stores on which the transaction should be started, null means all stores
-
Fetch
public Fetch(IStoreMessageChannelFactory<I, E> channelFactory, @Nullable Collection<String> stores, Map<String, ITuplePublisher<I>> tupleMapping) Fetches of a selection of stores, mapped automatically to the source topics that have the same name as the store.- Parameters:
channelFactory- the channel factory of the source to fetch the data fromstores- stores on which the transaction should be started, null means all storestupleMapping- mapping between the source topics and their respective tuple publishers
-
Fetch
public Fetch(IStoreMessageChannelFactory<I, E> channelFactory, Map<String, String> mapping, @Nullable Map<String, ITuplePublisher<I>> tupleMapping) Fetches a selection of topics into a selection of stores, with respect to the given topic/store mapping.- Parameters:
channelFactory- the channel factory of the source to fetch the data frommapping- mapping between source topics and destination storestupleMapping- mapping between the source topics and their respective tuple publishers
-
-
Method Details
-
defaultMapping
Creates a mapping between stores and topic, with stores names equals to the topic names.- Parameters:
stores- a collection of stores on which to create the mapping- Returns:
- default mapping for the given store names
-
fetch
Fetches data into theIEpoch.MASTER_BRANCH_NAMEbranch.- Parameters:
source- the data source to fetch data from- Returns:
- the schema transaction information
-
fetch
Fetches data in the specifiedbranchbranch. If the branch does not already exist, it will be created.- Parameters:
source- the data source to fetch data frombranch- the branch of the datastore to be updated- Returns:
- the schema transaction information
-
fetch
public IDatastoreSchemaTransactionInformation fetch(ISource<I, E> source, String branch, String parent) Main fetching method. This method:- starts the transaction
- creates the channels to add all the tuples that are parsed and fetches the data in a synchronous way
- commits the transaction on the specified
branchfrom the specified parent branch (ifbranchdoes not exist)
- Parameters:
source- the data source to fetch data frombranch- the name of branch to start the transaction onparent- the name of a branch on whichbranchwill be started. Ifparentis not null, thenbranchmust not be the name of an existing branch. Whenparentis null,branchstarts onIEpoch.MASTER_BRANCH_NAME.- Returns:
- the schema transaction information
-