mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-12-22 10:11:52 +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.decider.Decider;
|
||||||
import com.twitter.search.common.schema.earlybird.EarlybirdCluster;
|
import com.twitter.search.common.schema.earlybird.EarlybirdCluster;
|
||||||
import com.twitter.search.earlybird.EarlybirdIndexConfig;
|
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.archive.ArchiveSearchPartitionManager;
|
||||||
import com.twitter.search.earlybird.common.config.EarlybirdConfig;
|
import com.twitter.search.earlybird.common.config.EarlybirdConfig;
|
||||||
import com.twitter.search.earlybird.exception.CriticalExceptionHandler;
|
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;
|
import com.twitter.search.earlybird.partition.SearchIndexingMetricSet;
|
||||||
|
|
||||||
public final class EarlybirdIndexConfigUtil {
|
public final class EarlybirdIndexConfigUtil {
|
||||||
@ -20,19 +21,17 @@ public final class EarlybirdIndexConfigUtil {
|
|||||||
public static EarlybirdIndexConfig createEarlybirdIndexConfig(
|
public static EarlybirdIndexConfig createEarlybirdIndexConfig(
|
||||||
Decider decider, SearchIndexingMetricSet searchIndexingMetricSet,
|
Decider decider, SearchIndexingMetricSet searchIndexingMetricSet,
|
||||||
CriticalExceptionHandler criticalExceptionHandler) {
|
CriticalExceptionHandler criticalExceptionHandler) {
|
||||||
|
EarlybirdIndexConfigContext context = new EarlybirdIndexConfigContext();
|
||||||
if (isArchiveSearch()) {
|
if (isArchiveSearch()) {
|
||||||
return new ArchiveOnDiskEarlybirdIndexConfig(decider, searchIndexingMetricSet,
|
context.setStrategy(new ArchiveOnDiskEarlybirdIndexConfigStrategy());
|
||||||
criticalExceptionHandler);
|
|
||||||
} else if (isProtectedSearch()) {
|
} else if (isProtectedSearch()) {
|
||||||
return new RealtimeEarlybirdIndexConfig(
|
context.setStrategy(new RealtimeEarlybirdIndexConfigStrategy(EarlybirdCluster.PROTECTED));
|
||||||
EarlybirdCluster.PROTECTED, decider, searchIndexingMetricSet, criticalExceptionHandler);
|
|
||||||
} else if (isRealtimeCG()) {
|
} else if (isRealtimeCG()) {
|
||||||
return new RealtimeEarlybirdIndexConfig(
|
context.setStrategy(new RealtimeEarlybirdIndexConfigStrategy(EarlybirdCluster.REALTIME_CG));
|
||||||
EarlybirdCluster.REALTIME_CG, decider, searchIndexingMetricSet, criticalExceptionHandler);
|
|
||||||
} else {
|
} else {
|
||||||
return new RealtimeEarlybirdIndexConfig(
|
context.setStrategy(new RealtimeEarlybirdIndexConfigStrategy(EarlybirdCluster.REALTIME));
|
||||||
EarlybirdCluster.REALTIME, decider, searchIndexingMetricSet, criticalExceptionHandler);
|
|
||||||
}
|
}
|
||||||
|
return context.createEarlybirdIndexConfig(decider, searchIndexingMetricSet, criticalExceptionHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isArchiveSearch() {
|
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