![JAR search and dependency download from the Maven repository](/logo.png)
com.gs.fw.common.mithra.util.InactivateForArchivingLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reladomo Show documentation
Show all versions of reladomo Show documentation
Reladomo is an object-relational mapping framework.
/*
Copyright 2016 Goldman Sachs.
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 com.gs.fw.common.mithra.util;
import com.gs.collections.impl.list.mutable.FastList;
import com.gs.fw.common.mithra.MithraDatedTransactionalObject;
import com.gs.fw.common.mithra.MithraList;
import com.gs.fw.common.mithra.attribute.AsOfAttribute;
import com.gs.fw.common.mithra.attribute.Attribute;
import com.gs.fw.common.mithra.attribute.TupleAttribute;
import com.gs.fw.common.mithra.cache.FullUniqueIndex;
import com.gs.fw.common.mithra.finder.Operation;
import com.gs.fw.common.mithra.finder.RelatedFinder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Timestamp;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
public class InactivateForArchivingLoader
{
private static final Object END = new Object();
private static Logger logger = LoggerFactory.getLogger(InactivateForArchivingLoader.class.getName());
private RelatedFinder finder;
private AsOfAttribute businessDate;
private AsOfAttribute processingDate;
private Timestamp startTime;
private Timestamp endTime;
private int batchSize = 10000;
private LinkedBlockingQueue queue = new LinkedBlockingQueue(50);
private Attribute[] indexExtractor;
private Object sourceSourceAttribute;
private Object destinationSourceAttribute;
private int updateThreads = 1;
private int destinationReaderThreads = 5;
private long lastLogTime;
private int sourceRowsRead;
private AtomicInteger destinationRowsRead = new AtomicInteger();
private Throwable error;
private static final long LOG_PERIOD = 60000;
public InactivateForArchivingLoader(Timestamp startTime, Timestamp endTime, RelatedFinder finder, Object sourceSourceAttribute, Object destinationSourceAttribute)
{
this.startTime = startTime;
this.endTime = endTime;
this.finder = finder;
this.sourceSourceAttribute = sourceSourceAttribute;
this.destinationSourceAttribute = destinationSourceAttribute;
this.lastLogTime = System.currentTimeMillis();
AsOfAttribute[] finderAsOfAttributes = finder.getAsOfAttributes();
if (finderAsOfAttributes.length == 2)
{
businessDate = finderAsOfAttributes[0];
processingDate = finderAsOfAttributes[1];
}
if (finderAsOfAttributes.length == 1)
{
if (finderAsOfAttributes[0].isProcessingDate())
{
processingDate = finderAsOfAttributes[0];
}
else
{
throw new RuntimeException("Chained inactivation is only supported with processing date");
}
}
Attribute[] primaryKeyAttributes = finder.getPrimaryKeyAttributes();
indexExtractor = new Attribute[primaryKeyAttributes.length + finderAsOfAttributes.length - 1];
System.arraycopy(primaryKeyAttributes, 0, indexExtractor, 0, primaryKeyAttributes.length - 1); // don't copy the source attribute
for(int i=0;i 0)
{
putWithoutException(queue, buffers[0]);
}
}
catch (Throwable e)
{
logger.error("Error while reading source", e);
error = e;
}
finally
{
for(int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy