FaultTolerance faultTolerance = new FaultTolerance( context.getBoolean(FaultTolerance.IS_PRODUCTION_MODE, false), context.getBoolean(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false),
@Test public void testFaultTolerance() throws Exception { FaultTolerance tolerance = new FaultTolerance(true, false); tolerance = new FaultTolerance(true, true, IOException.class.getName()); tolerance.handleException(new IOException(), new Record()); tolerance = new FaultTolerance(true, true, IOException.class.getName()); tolerance.handleException(new RuntimeException(), new Record()); tolerance = new FaultTolerance(true, true, IOException.class.getName()); tolerance.handleException(new RuntimeException(new IOException()), new Record()); tolerance = new FaultTolerance(true, false, IOException.class.getName()); try { tolerance.handleException(new IOException(), new Record()); fail(); } catch (MorphlineRuntimeException e) { tolerance = new FaultTolerance(false, false, IOException.class.getName()); try { tolerance.handleException(new IOException(), new Record()); fail(); } catch (MorphlineRuntimeException e) { tolerance = new FaultTolerance(false, false, IOException.class.getName()); try { tolerance.handleException(new RuntimeException(), new Record()); fail(); } catch (MorphlineRuntimeException e) {
@Override public void handleException(Throwable t, Record record) { if (t instanceof Error) { throw (Error) t; // never ignore errors } if (isProductionMode()) { if (!isRecoverableException(t)) { LOG.warn("Ignoring unrecoverable exception in production mode for record: " + record, t); return; } else if (isIgnoringRecoverableExceptions()) { LOG.warn("Ignoring recoverable exception in production mode for record: " + record, t); return; } } throw new MorphlineRuntimeException(t); }
@Override public void handleException(Throwable t, Record record) { if (t instanceof Error) { throw (Error) t; // never ignore errors } if (isProductionMode()) { if (!isRecoverableException(t)) { LOG.warn("Ignoring unrecoverable exception in production mode for record: " + record, t); return; } else if (isIgnoringRecoverableExceptions()) { LOG.warn("Ignoring recoverable exception in production mode for record: " + record, t); return; } } throw new MorphlineRuntimeException(t); }
@Override protected void setup(Context context) throws IOException, InterruptedException { verifyPartitionAssignment(context); SolrRecordWriter.addReducerContext(context); Class<? extends UpdateConflictResolver> resolverClass = context.getConfiguration().getClass( UPDATE_CONFLICT_RESOLVER, RetainMostRecentUpdateConflictResolver.class, UpdateConflictResolver.class); this.resolver = ReflectionUtils.newInstance(resolverClass, context.getConfiguration()); /* * Note that ReflectionUtils.newInstance() above also implicitly calls * resolver.configure(context.getConfiguration()) if the resolver * implements org.apache.hadoop.conf.Configurable */ this.exceptionHandler = new FaultTolerance( context.getConfiguration().getBoolean(FaultTolerance.IS_PRODUCTION_MODE, false), context.getConfiguration().getBoolean(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false), context.getConfiguration().get(FaultTolerance.RECOVERABLE_EXCEPTION_CLASSES, SolrServerException.class.getName())); this.heartBeater = new HeartBeater(context); }
@Override protected void setup(Context context) throws IOException, InterruptedException { verifyPartitionAssignment(context); SolrRecordWriter.addReducerContext(context); Class<? extends UpdateConflictResolver> resolverClass = context.getConfiguration().getClass( UPDATE_CONFLICT_RESOLVER, RetainMostRecentUpdateConflictResolver.class, UpdateConflictResolver.class); this.resolver = ReflectionUtils.newInstance(resolverClass, context.getConfiguration()); /* * Note that ReflectionUtils.newInstance() above also implicitly calls * resolver.configure(context.getConfiguration()) if the resolver * implements org.apache.hadoop.conf.Configurable */ this.exceptionHandler = new FaultTolerance( context.getConfiguration().getBoolean(FaultTolerance.IS_PRODUCTION_MODE, false), context.getConfiguration().getBoolean(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false), context.getConfiguration().get(FaultTolerance.RECOVERABLE_EXCEPTION_CLASSES, SolrServerException.class.getName())); this.heartBeater = new HeartBeater(context); }
FaultTolerance faultTolerance = new FaultTolerance( configuration.getBoolean(FaultTolerance.IS_PRODUCTION_MODE, false), configuration.getBoolean(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false),
FaultTolerance faultTolerance = new FaultTolerance( configuration.getBoolean(FaultTolerance.IS_PRODUCTION_MODE, false), configuration.getBoolean(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false),
FaultTolerance faultTolerance = new FaultTolerance( getBooleanParameter(FaultTolerance.IS_PRODUCTION_MODE, false, params), getBooleanParameter(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false, params),
FaultTolerance faultTolerance = new FaultTolerance( getBooleanParameter(FaultTolerance.IS_PRODUCTION_MODE, false, params), getBooleanParameter(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false, params),
FaultTolerance faultTolerance = new FaultTolerance( getConfiguration().getBoolean(FaultTolerance.IS_PRODUCTION_MODE, false), getConfiguration().getBoolean(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false),
.setExceptionHandler(new FaultTolerance(isProduction, false)) .build();
private MorphlineContext createMorphlineContext() { return new MorphlineContext.Builder() .setExceptionHandler(new FaultTolerance(false, false, SolrServerException.class.getName())) .setMetricRegistry(new MetricRegistry()) .build(); }
FaultTolerance faultTolerance = new FaultTolerance( context.getBoolean(FaultTolerance.IS_PRODUCTION_MODE, false), context.getBoolean(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false),
private MorphlineContext createMorphlineContext() { return new SolrMorphlineContext.Builder() .setDocumentLoader(testServer) // .setDocumentLoader(new CollectingDocumentLoader(100)) .setExceptionHandler(new FaultTolerance(false, false, SolrServerException.class.getName())) .setMetricRegistry(new MetricRegistry()) .build(); }