mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-12-22 02:01:51 +01:00
Merge 559786574b
into 72eda9a24f
This commit is contained in:
commit
99c351cf48
@ -3,11 +3,12 @@ package com.twitter.search.earlybird.factory;
|
||||
import com.twitter.decider.Decider;
|
||||
import com.twitter.search.common.schema.earlybird.EarlybirdCluster;
|
||||
import com.twitter.search.earlybird.EarlybirdIndexConfig;
|
||||
import com.twitter.search.earlybird.RealtimeEarlybirdIndexConfig;
|
||||
import com.twitter.search.earlybird.archive.ArchiveOnDiskEarlybirdIndexConfig;
|
||||
import com.twitter.search.earlybird.archive.ArchiveSearchPartitionManager;
|
||||
import com.twitter.search.earlybird.common.config.EarlybirdConfig;
|
||||
import com.twitter.search.earlybird.exception.CriticalExceptionHandler;
|
||||
import com.twitter.search.earlybird.factory.configStrategy.ArchiveOnDiskEarlybirdIndexConfigStrategy;
|
||||
import com.twitter.search.earlybird.factory.configStrategy.EarlybirdIndexConfigContext;
|
||||
import com.twitter.search.earlybird.factory.configStrategy.RealtimeEarlybirdIndexConfigStrategy;
|
||||
import com.twitter.search.earlybird.partition.SearchIndexingMetricSet;
|
||||
|
||||
public final class EarlybirdIndexConfigUtil {
|
||||
@ -20,19 +21,17 @@ public final class EarlybirdIndexConfigUtil {
|
||||
public static EarlybirdIndexConfig createEarlybirdIndexConfig(
|
||||
Decider decider, SearchIndexingMetricSet searchIndexingMetricSet,
|
||||
CriticalExceptionHandler criticalExceptionHandler) {
|
||||
EarlybirdIndexConfigContext context = new EarlybirdIndexConfigContext();
|
||||
if (isArchiveSearch()) {
|
||||
return new ArchiveOnDiskEarlybirdIndexConfig(decider, searchIndexingMetricSet,
|
||||
criticalExceptionHandler);
|
||||
context.setStrategy(new ArchiveOnDiskEarlybirdIndexConfigStrategy());
|
||||
} else if (isProtectedSearch()) {
|
||||
return new RealtimeEarlybirdIndexConfig(
|
||||
EarlybirdCluster.PROTECTED, decider, searchIndexingMetricSet, criticalExceptionHandler);
|
||||
context.setStrategy(new RealtimeEarlybirdIndexConfigStrategy(EarlybirdCluster.PROTECTED));
|
||||
} else if (isRealtimeCG()) {
|
||||
return new RealtimeEarlybirdIndexConfig(
|
||||
EarlybirdCluster.REALTIME_CG, decider, searchIndexingMetricSet, criticalExceptionHandler);
|
||||
context.setStrategy(new RealtimeEarlybirdIndexConfigStrategy(EarlybirdCluster.REALTIME_CG));
|
||||
} else {
|
||||
return new RealtimeEarlybirdIndexConfig(
|
||||
EarlybirdCluster.REALTIME, decider, searchIndexingMetricSet, criticalExceptionHandler);
|
||||
context.setStrategy(new RealtimeEarlybirdIndexConfigStrategy(EarlybirdCluster.REALTIME));
|
||||
}
|
||||
return context.createEarlybirdIndexConfig(decider, searchIndexingMetricSet, criticalExceptionHandler);
|
||||
}
|
||||
|
||||
public static boolean isArchiveSearch() {
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.twitter.search.earlybird.factory.configStrategy;
|
||||
|
||||
import com.twitter.search.earlybird.EarlybirdIndexConfig;
|
||||
import com.twitter.search.earlybird.exception.CriticalExceptionHandler;
|
||||
import com.twitter.search.earlybird.partition.SearchIndexingMetricSet;
|
||||
|
||||
public class EarlybirdIndexConfigContext {
|
||||
private EarlybirdIndexConfigStrategy strategy;
|
||||
|
||||
public void setStrategy(EarlybirdIndexConfigStrategy strategy) {
|
||||
this.strategy = strategy;
|
||||
}
|
||||
|
||||
public EarlybirdIndexConfig createEarlybirdIndexConfig(
|
||||
Decider decider, SearchIndexingMetricSet searchIndexingMetricSet,
|
||||
CriticalExceptionHandler criticalExceptionHandler) {
|
||||
return strategy.createEarlybirdIndexConfig(decider, searchIndexingMetricSet, criticalExceptionHandler);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.twitter.search.earlybird.factory.configStrategy;
|
||||
|
||||
import com.twitter.search.earlybird.EarlybirdIndexConfig;
|
||||
import com.twitter.search.earlybird.archive.ArchiveOnDiskEarlybirdIndexConfig;
|
||||
import com.twitter.search.earlybird.exception.CriticalExceptionHandler;
|
||||
import com.twitter.search.earlybird.partition.SearchIndexingMetricSet;
|
||||
|
||||
public interface EarlybirdIndexConfigStrategy {
|
||||
EarlybirdIndexConfig createEarlybirdIndexConfig(
|
||||
Decider decider, SearchIndexingMetricSet searchIndexingMetricSet,
|
||||
CriticalExceptionHandler criticalExceptionHandler);
|
||||
}
|
||||
|
||||
public class ArchiveOnDiskEarlybirdIndexConfigStrategy implements EarlybirdIndexConfigStrategy {
|
||||
@Override
|
||||
public EarlybirdIndexConfig createEarlybirdIndexConfig(
|
||||
Decider decider, SearchIndexingMetricSet searchIndexingMetricSet,
|
||||
CriticalExceptionHandler criticalExceptionHandler) {
|
||||
return new ArchiveOnDiskEarlybirdIndexConfig(decider, searchIndexingMetricSet, criticalExceptionHandler);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.twitter.search.earlybird.factory.configStrategy;
|
||||
|
||||
import com.twitter.search.common.schema.earlybird.EarlybirdCluster;
|
||||
import com.twitter.search.earlybird.EarlybirdIndexConfig;
|
||||
import com.twitter.search.earlybird.RealtimeEarlybirdIndexConfig;
|
||||
import com.twitter.search.earlybird.exception.CriticalExceptionHandler;
|
||||
import com.twitter.search.earlybird.partition.SearchIndexingMetricSet;
|
||||
|
||||
public class RealtimeEarlybirdIndexConfigStrategy implements EarlybirdIndexConfigStrategy {
|
||||
private EarlybirdCluster earlybirdCluster;
|
||||
|
||||
public RealtimeEarlybirdIndexConfigStrategy(EarlybirdCluster earlybirdCluster) {
|
||||
this.earlybirdCluster = earlybirdCluster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EarlybirdIndexConfig createEarlybirdIndexConfig(
|
||||
Decider decider, SearchIndexingMetricSet searchIndexingMetricSet,
|
||||
CriticalExceptionHandler criticalExceptionHandler) {
|
||||
return new RealtimeEarlybirdIndexConfig(
|
||||
earlybirdCluster, decider, searchIndexingMetricSet, criticalExceptionHandler);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user