    @SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testNextMaxResults_HappyPathUsingDeprecatedConstructor() throws Exception {
        // Set local test input
        String userDN = "userDN";
        String userSid = "userSid";
        UUID queryId = UUID.randomUUID();
        String methodAuths = "AUTH_1";
        DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of("userDN", "issuerDN"), UserType.USER, Collections.singleton(methodAuths), null, null, 0L);
        DatawavePrincipal principal = new DatawavePrincipal(Collections.singletonList(user));
        String query = "query";
        String queryLogicName = "queryLogicName";
        String queryName = "queryName";
        long currentTime = System.currentTimeMillis();
        Date beginDate = new Date(currentTime - 5000);
        Date endDate = new Date(currentTime - 1000);
        Date expirationDate = new Date(currentTime + 9999);
        String queryAuthorizations = methodAuths;
        int pageSize = 5;
        int maxPageSize = 5;

        long pageByteTrigger = 4 * 1024L;
        long maxRowsToScan = Long.MAX_VALUE;
        long maxResults = 4L;
        List<Object> resultObjects = Arrays.asList(new Object(), "resultObject1", "resultObject2", "resultObject3", "resultObject4", "resultObject5");

        // Set expectations
        expect(this.queryLogic.getCollectQueryMetrics()).andReturn(true);
        this.query.populateMetric(isA(QueryMetric.class));
        expect(this.query.getUncaughtExceptionHandler()).andReturn(exceptionHandler).times(7);
        expect(this.exceptionHandler.getThrowable()).andReturn(null).times(7);
        expect(this.query.getId()).andReturn(queryId).times(3);
        expect(this.query.getOwner()).andReturn(userSid);
        expect(this.query.getQuery()).andReturn(query);
        expect(this.query.getQueryLogicName()).andReturn(queryLogicName);
        expect(this.query.getQueryName()).andReturn(queryName);
        expect(this.query.getBeginDate()).andReturn(beginDate);
        expect(this.query.getEndDate()).andReturn(endDate);
        expect(this.query.getExpirationDate()).andReturn(expirationDate);
        expect(this.query.getParameters()).andReturn(new HashSet<>());
        expect(this.query.getQueryAuthorizations()).andReturn(queryAuthorizations);
        expect(this.query.getUserDN()).andReturn(userDN).times(2);
        expect(this.queryLogic.initialize(eq(this.connector), eq(this.query), isA(Set.class))).andReturn(this.genericConfiguration);
        this.queryLogic.setupQuery(this.genericConfiguration);
        expect(this.queryLogic.getTransformIterator(this.query)).andReturn(this.transformIterator);

        Iterator<Object> iterator = resultObjects.iterator();
        int count = 0;
        expect(this.transformIterator.hasNext()).andReturn(iterator.hasNext());
        while (iterator.hasNext() && count < maxResults) {
            expect(this.transformIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.transformIterator.next()).andReturn(iterator.next());
            count++;
        }

        expect(this.query.getPagesize()).andReturn(pageSize).anyTimes();
        expect(this.queryLogic.getMaxPageSize()).andReturn(maxPageSize).anyTimes();
        expect(this.queryLogic.getPageByteTrigger()).andReturn(pageByteTrigger).anyTimes();
        expect(this.queryLogic.getMaxRowsToScan()).andReturn(maxRowsToScan).anyTimes();
        expect(this.queryLogic.getMaxResults()).andReturn(maxResults).anyTimes();
        expect(this.genericConfiguration.getQueryString()).andReturn(query).once();

        // Run the test
        PowerMock.replayAll();
        RunningQuery subject = new RunningQuery(this.connector, Priority.NORMAL, this.queryLogic, this.query, methodAuths, principal,
                        new QueryMetricFactoryImpl());

        ResultsPage result1 = subject.next();

        String result2 = subject.toString();
        QueryMetric.Lifecycle status = subject.getMetric().getLifecycle();
        PowerMock.verifyAll();

        // Verify results
        assertTrue("Expected a non-null page", null != result1);
        assertTrue("Expected a non-null list of results", null != result1.getResults());
        assertTrue("Expected MAXRESULTS non-null items in the list of results", resultObjects.size() > maxResults);
        assertTrue("Expected status to be MAXRESULTS", status == QueryMetric.Lifecycle.MAXRESULTS);

        assertTrue("Expected a non-null toString() representation", null != result2);
    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testNextMaxResults_HappyPathUsingDeprecatedConstructor() throws Exception {
        // Set local test input
        String userDN = "userDN";
        String userSid = "userSid";
        UUID queryId = UUID.randomUUID();
        String methodAuths = "AUTH_1";
        DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of("userDN", "issuerDN"), UserType.USER, Collections.singleton(methodAuths), null, null, 0L);
        DatawavePrincipal principal = new DatawavePrincipal(Collections.singletonList(user));
        String query = "query";
        String queryLogicName = "queryLogicName";
        String queryName = "queryName";
        long currentTime = System.currentTimeMillis();
        Date beginDate = new Date(currentTime - 5000);
        Date endDate = new Date(currentTime - 1000);
        Date expirationDate = new Date(currentTime + 9999);
        String queryAuthorizations = methodAuths;
        int pageSize = 5;
        int maxPageSize = 5;

        long pageByteTrigger = 4 * 1024L;
        long maxRowsToScan = Long.MAX_VALUE;
        long maxResults = 4L;
        List<Object> resultObjects = Arrays.asList(new Object(), "resultObject1", "resultObject2", "resultObject3", "resultObject4", "resultObject5");

        // Set expectations
        expect(this.queryLogic.getCollectQueryMetrics()).andReturn(true);
        this.query.populateMetric(isA(QueryMetric.class));
        expect(this.query.getUncaughtExceptionHandler()).andReturn(exceptionHandler).times(7);
        expect(this.exceptionHandler.getThrowable()).andReturn(null).times(7);
        expect(this.query.getId()).andReturn(queryId).times(3);
        expect(this.query.getOwner()).andReturn(userSid);
        expect(this.query.getQuery()).andReturn(query);
        expect(this.query.getQueryLogicName()).andReturn(queryLogicName);
        expect(this.query.getQueryName()).andReturn(queryName);
        expect(this.query.getBeginDate()).andReturn(beginDate);
        expect(this.query.getEndDate()).andReturn(endDate);
        expect(this.query.getExpirationDate()).andReturn(expirationDate);
        expect(this.query.getParameters()).andReturn(new HashSet<Parameter>());
        expect(this.query.getQueryAuthorizations()).andReturn(queryAuthorizations);
        expect(this.query.getUserDN()).andReturn(userDN).times(2);
        expect(this.queryLogic.initialize(eq(this.connector), eq(this.query), isA(Set.class))).andReturn(this.genericConfiguration);
        this.queryLogic.setupQuery(this.genericConfiguration);
        expect(this.queryLogic.getTransformIterator(this.query)).andReturn(this.transformIterator);

        Iterator<Object> iterator = resultObjects.iterator();
        int count = 0;
        expect(this.transformIterator.hasNext()).andReturn(iterator.hasNext());
        while (iterator.hasNext() && count < maxResults) {
            expect(this.transformIterator.hasNext()).andReturn(iterator.hasNext());
            expect(this.transformIterator.next()).andReturn(iterator.next());
            count++;
        }

        expect(this.query.getPagesize()).andReturn(pageSize).anyTimes();
        expect(this.queryLogic.getMaxPageSize()).andReturn(maxPageSize).anyTimes();
        expect(this.queryLogic.getPageByteTrigger()).andReturn(pageByteTrigger).anyTimes();
        expect(this.queryLogic.getMaxRowsToScan()).andReturn(maxRowsToScan).anyTimes();
        expect(this.queryLogic.getMaxResults()).andReturn(maxResults).anyTimes();
        expect(this.genericConfiguration.getQueryString()).andReturn(query).once();

        // Run the test
        PowerMock.replayAll();
        RunningQuery subject = new RunningQuery(this.connector, Priority.NORMAL, this.queryLogic, this.query, methodAuths, principal,
                        new QueryMetricFactoryImpl());

        ResultsPage result1 = subject.next();

        String result2 = subject.toString();
        QueryMetric.Lifecycle status = subject.getMetric().getLifecycle();
        PowerMock.verifyAll();

        // Verify results
        assertTrue("Expected a non-null page", null != result1);
        assertTrue("Expected a non-null list of results", null != result1.getResults());
        assertTrue("Expected MAXRESULTS non-null items in the list of results", resultObjects.size() > maxResults);
        assertTrue("Expected status to be MAXRESULTS", status == QueryMetric.Lifecycle.MAXRESULTS);

        assertTrue("Expected a non-null toString() representation", null != result2);
    }

Replace Generic With Diamond HashSet<Parameter> with HashSet<> in method public testNextMaxResults_HappyPathUsingDeprecatedConstructor() : void from class datawave.webservice.query.runner.ExtendedRunningQueryTest


    @SuppressWarnings("unchecked")
    @Test
    public void testPredict() throws Exception {
        QueryImpl q = createNewQuery();
        MultivaluedMap p = createNewQueryParameterMap();

        MultivaluedMap<String,String> optionalParameters = createNewQueryParameters(q, p);

        @SuppressWarnings("rawtypes")
        QueryLogic logic = createMock(BaseQueryLogic.class);

        DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of(userDN, "<CN=MY_CA, OU=MY_SUBDIVISION, OU=MY_DIVISION, O=ORG, C=US>"), UserType.USER,
                        Arrays.asList(auths), null, null, 0L);
        DatawavePrincipal principal = new DatawavePrincipal(Collections.singletonList(user));
        String[] dns = principal.getDNs();
        Arrays.sort(dns);
        List<String> dnList = Arrays.asList(dns);

        PowerMock.resetAll();
        EasyMock.expect(ctx.getCallerPrincipal()).andReturn(principal).anyTimes();
        suppress(constructor(QueryParametersImpl.class));
        EasyMock.expect(persister.create(principal.getUserDN().subjectDN(), dnList, (SecurityMarking) Whitebox.getField(bean.getClass(), "marking").get(bean),
                        queryLogicName, (QueryParameters) Whitebox.getField(bean.getClass(), "qp").get(bean), optionalParameters)).andReturn(q);

        EasyMock.expect(queryLogicFactory.getQueryLogic(queryLogicName, principal)).andReturn(logic);
        EasyMock.expect(logic.getRequiredQueryParameters()).andReturn(Collections.EMPTY_SET);
        EasyMock.expect(logic.getMaxPageSize()).andReturn(0);

        BaseQueryMetric metric = new QueryMetricFactoryImpl().createMetric();
        q.populateMetric(metric);
        metric.setQueryType(RunningQuery.class.getSimpleName());

        QueryMetric testMetric = new QueryMetric((QueryMetric) metric) {
            @Override
            public boolean equals(Object o) {
                // test for equality except for the create date
                if (null == o) {
                    return false;
                }
                if (this == o) {
                    return true;
                }
                if (o instanceof QueryMetric) {
                    QueryMetric other = (QueryMetric) o;
                    return new EqualsBuilder().append(this.getQueryId(), other.getQueryId()).append(this.getQueryType(), other.getQueryType())
                                    .append(this.getQueryAuthorizations(), other.getQueryAuthorizations())
                                    .append(this.getColumnVisibility(), other.getColumnVisibility()).append(this.getBeginDate(), other.getBeginDate())
                                    .append(this.getEndDate(), other.getEndDate()).append(this.getCreateDate(), other.getCreateDate())
                                    .append(this.getSetupTime(), other.getSetupTime()).append(this.getUser(), other.getUser())
                                    .append(this.getUserDN(), other.getUserDN()).append(this.getQuery(), other.getQuery())
                                    .append(this.getQueryLogic(), other.getQueryLogic()).append(this.getQueryName(), other.getQueryName())
                                    .append(this.getParameters(), other.getParameters()).append(this.getHost(), other.getHost())
                                    .append(this.getPageTimes(), other.getPageTimes()).append(this.getProxyServers(), other.getProxyServers())
                                    .append(this.getLifecycle(), other.getLifecycle()).append(this.getErrorMessage(), other.getErrorMessage())
                                    .append(this.getErrorCode(), other.getErrorCode()).append(this.getSourceCount(), other.getSourceCount())
                                    .append(this.getNextCount(), other.getNextCount()).append(this.getSeekCount(), other.getSeekCount())
                                    .append(this.getDocRanges(), other.getDocRanges()).append(this.getFiRanges(), other.getFiRanges())
                                    .append(this.getPlan(), other.getPlan()).append(this.getLoginTime(), other.getLoginTime())
                                    .append(this.getPredictions(), other.getPredictions()).isEquals();
                } else {
                    return false;
                }

            }
        };

        Set<Prediction> predictions = new HashSet<>();
        predictions.add(new Prediction("source", 1));
        EasyMock.expect(predictor.predict(EasyMock.eq(testMetric))).andReturn(predictions);

        PowerMock.replayAll();

        GenericResponse<String> response = bean.predictQuery(queryLogicName, p);

        PowerMock.verifyAll();

        Object cachedRunningQuery = cache.get(q.getId().toString());
        Assert.assertNull(cachedRunningQuery);

        Assert.assertEquals(predictions.toString(), response.getResult());
    }

    @SuppressWarnings("unchecked")
    @Test
    public void testPredict() throws Exception {
        QueryImpl q = createNewQuery();
        MultivaluedMap p = createNewQueryParameterMap();

        MultivaluedMap<String,String> optionalParameters = createNewQueryParameters(q, p);

        @SuppressWarnings("rawtypes")
        QueryLogic logic = createMock(BaseQueryLogic.class);

        DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of(userDN, "<CN=MY_CA, OU=MY_SUBDIVISION, OU=MY_DIVISION, O=ORG, C=US>"), UserType.USER,
                        Arrays.asList(auths), null, null, 0L);
        DatawavePrincipal principal = new DatawavePrincipal(Collections.singletonList(user));
        String[] dns = principal.getDNs();
        Arrays.sort(dns);
        List<String> dnList = Arrays.asList(dns);

        PowerMock.resetAll();
        EasyMock.expect(ctx.getCallerPrincipal()).andReturn(principal).anyTimes();
        suppress(constructor(QueryParametersImpl.class));
        EasyMock.expect(persister.create(principal.getUserDN().subjectDN(), dnList, (SecurityMarking) Whitebox.getField(bean.getClass(), "marking").get(bean),
                        queryLogicName, (QueryParameters) Whitebox.getField(bean.getClass(), "qp").get(bean), optionalParameters)).andReturn(q);

        EasyMock.expect(queryLogicFactory.getQueryLogic(queryLogicName, principal)).andReturn(logic);
        EasyMock.expect(logic.getRequiredQueryParameters()).andReturn(Collections.EMPTY_SET);
        EasyMock.expect(logic.getMaxPageSize()).andReturn(0);

        BaseQueryMetric metric = new QueryMetricFactoryImpl().createMetric();
        q.populateMetric(metric);
        metric.setQueryType(RunningQuery.class.getSimpleName());

        QueryMetric testMetric = new QueryMetric((QueryMetric) metric) {
            @Override
            public boolean equals(Object o) {
                // test for equality except for the create date
                if (null == o) {
                    return false;
                }
                if (this == o) {
                    return true;
                }
                if (o instanceof QueryMetric) {
                    QueryMetric other = (QueryMetric) o;
                    return new EqualsBuilder().append(this.getQueryId(), other.getQueryId()).append(this.getQueryType(), other.getQueryType())
                                    .append(this.getQueryAuthorizations(), other.getQueryAuthorizations())
                                    .append(this.getColumnVisibility(), other.getColumnVisibility()).append(this.getBeginDate(), other.getBeginDate())
                                    .append(this.getEndDate(), other.getEndDate()).append(this.getCreateDate(), other.getCreateDate())
                                    .append(this.getSetupTime(), other.getSetupTime()).append(this.getUser(), other.getUser())
                                    .append(this.getUserDN(), other.getUserDN()).append(this.getQuery(), other.getQuery())
                                    .append(this.getQueryLogic(), other.getQueryLogic()).append(this.getQueryName(), other.getQueryName())
                                    .append(this.getParameters(), other.getParameters()).append(this.getHost(), other.getHost())
                                    .append(this.getPageTimes(), other.getPageTimes()).append(this.getProxyServers(), other.getProxyServers())
                                    .append(this.getLifecycle(), other.getLifecycle()).append(this.getErrorMessage(), other.getErrorMessage())
                                    .append(this.getErrorCode(), other.getErrorCode()).append(this.getSourceCount(), other.getSourceCount())
                                    .append(this.getNextCount(), other.getNextCount()).append(this.getSeekCount(), other.getSeekCount())
                                    .append(this.getDocRanges(), other.getDocRanges()).append(this.getFiRanges(), other.getFiRanges())
                                    .append(this.getPlan(), other.getPlan()).append(this.getLoginTime(), other.getLoginTime())
                                    .append(this.getPredictions(), other.getPredictions()).isEquals();
                } else {
                    return false;
                }

            }
        };

        Set<Prediction> predictions = new HashSet<Prediction>();
        predictions.add(new Prediction("source", 1));
        EasyMock.expect(predictor.predict(EasyMock.eq(testMetric))).andReturn(predictions);

        PowerMock.replayAll();

        GenericResponse<String> response = bean.predictQuery(queryLogicName, p);

        PowerMock.verifyAll();

        Object cachedRunningQuery = cache.get(q.getId().toString());
        Assert.assertNull(cachedRunningQuery);

        Assert.assertEquals(predictions.toString(), response.getResult());
    }

Replace Generic With Diamond HashSet<Prediction> with HashSet<> in method public testPredict() : void from class datawave.webservice.query.runner.QueryExecutorBeanTest


    @SuppressWarnings("unchecked")
    @Test(timeout = 5000)
    public void testCloseActuallyCloses() throws Exception {
        QueryImpl q = createNewQuery();

        final MultivaluedMap<String,String> queryParameters = createNewQueryParameterMap();

        final Thread createQuery = new Thread(() -> {
            try {
                bean.createQuery("EventQueryLogic", queryParameters);
            } catch (Exception e) {
                // ok if we fail the call
                        log.debug("createQuery terminated with " + e);
                    }
                });

        final Throwable[] createQueryException = {null};
        createQuery.setUncaughtExceptionHandler((t, e) -> createQueryException[0] = e);

        @SuppressWarnings("rawtypes")
        QueryLogic logic = createMock(BaseQueryLogic.class);

        DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of(userDN, "<CN=MY_CA, OU=MY_SUBDIVISION, OU=MY_DIVISION, O=ORG, C=US>"), UserType.USER,
                        Arrays.asList(auths), null, null, 0L);
        DatawavePrincipal principal = new DatawavePrincipal(Collections.singletonList(user));
        principal.getShortName();
        String[] dns = principal.getDNs();
        Arrays.sort(dns);
        List<String> dnList = Arrays.asList(dns);

        InMemoryInstance instance = new InMemoryInstance();
        Connector c = instance.getConnector("root", new PasswordToken(""));

        MultivaluedMap<String,String> optionalParameters = createNewQueryParameters(q, queryParameters);
        // QueryParameters qp = new QueryParametersImpl();
        // qp.validate(queryParameters);
        // MultivaluedMap<String,String> optionalParameters = qp.getUnknownParameters(queryParameters);
        // optionalParameters.putSingle(AuditParameters.USER_DN, principal.getUserDN().subjectDN());
        // optionalParameters.putSingle(AuditParameters.QUERY_SECURITY_MARKING_COLVIZ, q.getColumnVisibility());
        // optionalParameters.putSingle("logicClass", queryLogicName);

        PowerMock.resetAll();
        EasyMock.expect(ctx.getCallerPrincipal()).andReturn(principal).anyTimes();
        EasyMock.expect(logic.getAuditType(null)).andReturn(AuditType.NONE);
        EasyMock.expect(persister.create(principal.getUserDN().subjectDN(), dnList, Whitebox.getInternalState(bean, SecurityMarking.class), queryLogicName,
                        Whitebox.getInternalState(bean, QueryParameters.class), optionalParameters)).andReturn(q);
        persister.remove(q);
        EasyMock.expect(connectionFactory.getTrackingMap((StackTraceElement[]) anyObject())).andReturn(Maps.<String,String> newHashMap()).anyTimes();

        BaseQueryMetric metric = new QueryMetricFactoryImpl().createMetric();
        q.populateMetric(metric);
        EasyMock.expectLastCall();
        metric.setQueryType(RunningQuery.class.getSimpleName());
        metric.setLifecycle(Lifecycle.DEFINED);
        System.out.println(metric.toString());

        Set<Prediction> predictions = new HashSet<>();
        predictions.add(new Prediction("source", 1));
        EasyMock.expect(predictor.predict(metric)).andReturn(predictions);

        connectionRequestBean.requestBegin(q.getId().toString());
        EasyMock.expectLastCall();
        EasyMock.expect(connectionFactory.getConnection(eq("connPool1"), (AccumuloConnectionFactory.Priority) anyObject(), (Map<String,String>) anyObject()))
                        .andReturn(c).anyTimes();
        connectionRequestBean.requestEnd(q.getId().toString());
        EasyMock.expectLastCall();
        connectionFactory.returnConnection(c);
        EasyMock.expectLastCall();

        EasyMock.expect(queryLogicFactory.getQueryLogic(queryLogicName, principal)).andReturn(logic);
        EasyMock.expect(logic.getRequiredQueryParameters()).andReturn(Collections.emptySet());
        EasyMock.expect(logic.getConnectionPriority()).andReturn(AccumuloConnectionFactory.Priority.NORMAL).atLeastOnce();
        EasyMock.expect(logic.getMaxPageSize()).andReturn(0);
        EasyMock.expect(logic.getAuditType(q)).andReturn(AuditType.NONE);
        EasyMock.expect(logic.getConnPoolName()).andReturn("connPool1");

        EasyMock.expect(connectionRequestBean.cancelConnectionRequest(q.getId().toString(), principal)).andReturn(false);
        connectionFactory.returnConnection(EasyMock.isA(Connector.class));

        final AtomicBoolean initializeLooping = new AtomicBoolean(false);

        // During initialize, mark that we get here, and then sleep
        final IAnswer<GenericQueryConfiguration> initializeAnswer = () -> {
            initializeLooping.set(true);
            try {
                while (true) {
                    Thread.sleep(1000);
                    log.debug("Initialize: woke up");
                }
            } catch (InterruptedException e) {
                throw new QueryException("EXPECTED EXCEPTION: initialize interrupted");
            }
        };

        EasyMock.expect(logic.initialize(anyObject(Connector.class), anyObject(Query.class), anyObject(Set.class))).andAnswer(initializeAnswer);
        EasyMock.expect(logic.getCollectQueryMetrics()).andReturn(Boolean.FALSE);

        // On close, interrupt the thread to simulate the ScannerFactory cleaning up
        final IAnswer<Object> closeAnswer = () -> {
            if (null != createQuery) {
                log.debug("createQuery thread is not null. interrupting");
                createQuery.interrupt();
            } else {
                log.debug("createQuery thread is null. not interrupting");
            }
            return null;
        };

        logic.close();
        EasyMock.expectLastCall().andAnswer(closeAnswer).anyTimes();

        // Make the QueryLogic mock not threadsafe, otherwise it will be blocked infinitely
        // trying to get the lock on the infinite loop
        EasyMock.makeThreadSafe(logic, false);

        metrics.updateMetric(EasyMock.isA(QueryMetric.class));

        PowerMock.replayAll();
        try {
            createQuery.start();

            // Wait for the create call to get to initialize
            while (!initializeLooping.get()) {
                if (!createQuery.isAlive() && !initializeLooping.get()) {
                    Assert.fail("createQuery thread died before reaching initialize: " + createQueryException[0]);
                }
                Thread.sleep(50);
            }

            // initialize has not completed yet so it will not appear in the cache
            Object cachedRunningQuery = cache.get(q.getId().toString());
            Assert.assertNull(cachedRunningQuery);
            Pair<QueryLogic<?>,Connector> pair = qlCache.poll(q.getId().toString());
            Assert.assertNotNull(pair);
            Assert.assertEquals(logic, pair.getFirst());
            Assert.assertEquals(c, pair.getSecond());

            // Have to add these back because poll was destructive
            qlCache.add(q.getId().toString(), principal.getShortName(), pair.getFirst(), pair.getSecond());

            // Call close
            bean.close(q.getId().toString());

            // Make sure that it's gone from the qlCache
            pair = qlCache.poll(q.getId().toString());
            Assert.assertNull("Still found an entry in the qlCache: " + pair, pair);

            // Should have already joined by now, but just to be sure
            createQuery.join();
        } finally {
            if (null != createQuery && createQuery.isAlive()) {
                createQuery.interrupt();
            }
        }
    }

    @SuppressWarnings("unchecked")
    @Test(timeout = 5000)
    public void testCloseActuallyCloses() throws Exception {
        QueryImpl q = createNewQuery();

        final MultivaluedMap<String,String> queryParameters = createNewQueryParameterMap();

        final Thread createQuery = new Thread(() -> {
            try {
                bean.createQuery("EventQueryLogic", queryParameters);
            } catch (Exception e) {
                // ok if we fail the call
                        log.debug("createQuery terminated with " + e);
                    }
                });

        final Throwable[] createQueryException = {null};
        createQuery.setUncaughtExceptionHandler((t, e) -> createQueryException[0] = e);

        @SuppressWarnings("rawtypes")
        QueryLogic logic = createMock(BaseQueryLogic.class);

        DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of(userDN, "<CN=MY_CA, OU=MY_SUBDIVISION, OU=MY_DIVISION, O=ORG, C=US>"), UserType.USER,
                        Arrays.asList(auths), null, null, 0L);
        DatawavePrincipal principal = new DatawavePrincipal(Collections.singletonList(user));
        principal.getShortName();
        String[] dns = principal.getDNs();
        Arrays.sort(dns);
        List<String> dnList = Arrays.asList(dns);

        InMemoryInstance instance = new InMemoryInstance();
        Connector c = instance.getConnector("root", new PasswordToken(""));

        MultivaluedMap<String,String> optionalParameters = createNewQueryParameters(q, queryParameters);
        // QueryParameters qp = new QueryParametersImpl();
        // qp.validate(queryParameters);
        // MultivaluedMap<String,String> optionalParameters = qp.getUnknownParameters(queryParameters);
        // optionalParameters.putSingle(AuditParameters.USER_DN, principal.getUserDN().subjectDN());
        // optionalParameters.putSingle(AuditParameters.QUERY_SECURITY_MARKING_COLVIZ, q.getColumnVisibility());
        // optionalParameters.putSingle("logicClass", queryLogicName);

        PowerMock.resetAll();
        EasyMock.expect(ctx.getCallerPrincipal()).andReturn(principal).anyTimes();
        EasyMock.expect(logic.getAuditType(null)).andReturn(AuditType.NONE);
        EasyMock.expect(persister.create(principal.getUserDN().subjectDN(), dnList, Whitebox.getInternalState(bean, SecurityMarking.class), queryLogicName,
                        Whitebox.getInternalState(bean, QueryParameters.class), optionalParameters)).andReturn(q);
        persister.remove(q);
        EasyMock.expect(connectionFactory.getTrackingMap((StackTraceElement[]) anyObject())).andReturn(Maps.<String,String> newHashMap()).anyTimes();

        BaseQueryMetric metric = new QueryMetricFactoryImpl().createMetric();
        q.populateMetric(metric);
        EasyMock.expectLastCall();
        metric.setQueryType(RunningQuery.class.getSimpleName());
        metric.setLifecycle(Lifecycle.DEFINED);
        System.out.println(metric.toString());

        Set<Prediction> predictions = new HashSet<Prediction>();
        predictions.add(new Prediction("source", 1));
        EasyMock.expect(predictor.predict(metric)).andReturn(predictions);

        connectionRequestBean.requestBegin(q.getId().toString());
        EasyMock.expectLastCall();
        EasyMock.expect(connectionFactory.getConnection(eq("connPool1"), (AccumuloConnectionFactory.Priority) anyObject(), (Map<String,String>) anyObject()))
                        .andReturn(c).anyTimes();
        connectionRequestBean.requestEnd(q.getId().toString());
        EasyMock.expectLastCall();
        connectionFactory.returnConnection(c);
        EasyMock.expectLastCall();

        EasyMock.expect(queryLogicFactory.getQueryLogic(queryLogicName, principal)).andReturn(logic);
        EasyMock.expect(logic.getRequiredQueryParameters()).andReturn(Collections.emptySet());
        EasyMock.expect(logic.getConnectionPriority()).andReturn(AccumuloConnectionFactory.Priority.NORMAL).atLeastOnce();
        EasyMock.expect(logic.getMaxPageSize()).andReturn(0);
        EasyMock.expect(logic.getAuditType(q)).andReturn(AuditType.NONE);
        EasyMock.expect(logic.getConnPoolName()).andReturn("connPool1");

        EasyMock.expect(connectionRequestBean.cancelConnectionRequest(q.getId().toString(), principal)).andReturn(false);
        connectionFactory.returnConnection(EasyMock.isA(Connector.class));

        final AtomicBoolean initializeLooping = new AtomicBoolean(false);

        // During initialize, mark that we get here, and then sleep
        final IAnswer<GenericQueryConfiguration> initializeAnswer = () -> {
            initializeLooping.set(true);
            try {
                while (true) {
                    Thread.sleep(1000);
                    log.debug("Initialize: woke up");
                }
            } catch (InterruptedException e) {
                throw new QueryException("EXPECTED EXCEPTION: initialize interrupted");
            }
        };

        EasyMock.expect(logic.initialize(anyObject(Connector.class), anyObject(Query.class), anyObject(Set.class))).andAnswer(initializeAnswer);
        EasyMock.expect(logic.getCollectQueryMetrics()).andReturn(Boolean.FALSE);

        // On close, interrupt the thread to simulate the ScannerFactory cleaning up
        final IAnswer<Object> closeAnswer = () -> {
            if (null != createQuery) {
                log.debug("createQuery thread is not null. interrupting");
                createQuery.interrupt();
            } else {
                log.debug("createQuery thread is null. not interrupting");
            }
            return null;
        };

        logic.close();
        EasyMock.expectLastCall().andAnswer(closeAnswer).anyTimes();

        // Make the QueryLogic mock not threadsafe, otherwise it will be blocked infinitely
        // trying to get the lock on the infinite loop
        EasyMock.makeThreadSafe(logic, false);

        metrics.updateMetric(EasyMock.isA(QueryMetric.class));

        PowerMock.replayAll();
        try {
            createQuery.start();

            // Wait for the create call to get to initialize
            while (!initializeLooping.get()) {
                if (!createQuery.isAlive() && !initializeLooping.get()) {
                    Assert.fail("createQuery thread died before reaching initialize: " + createQueryException[0]);
                }
                Thread.sleep(50);
            }

            // initialize has not completed yet so it will not appear in the cache
            Object cachedRunningQuery = cache.get(q.getId().toString());
            Assert.assertNull(cachedRunningQuery);
            Pair<QueryLogic<?>,Connector> pair = qlCache.poll(q.getId().toString());
            Assert.assertNotNull(pair);
            Assert.assertEquals(logic, pair.getFirst());
            Assert.assertEquals(c, pair.getSecond());

            // Have to add these back because poll was destructive
            qlCache.add(q.getId().toString(), principal.getShortName(), pair.getFirst(), pair.getSecond());

            // Call close
            bean.close(q.getId().toString());

            // Make sure that it's gone from the qlCache
            pair = qlCache.poll(q.getId().toString());
            Assert.assertNull("Still found an entry in the qlCache: " + pair, pair);

            // Should have already joined by now, but just to be sure
            createQuery.join();
        } finally {
            if (null != createQuery && createQuery.isAlive()) {
                createQuery.interrupt();
            }
        }
    }

Replace Generic With Diamond HashSet<Prediction> with HashSet<> in method public testCloseActuallyCloses() : void from class datawave.webservice.query.runner.QueryExecutorBeanTest


    public Unique() {
        super(QueryFunctions.UNIQUE_FUNCTION, new ArrayList<>());
    }

    public Unique() {
        super(QueryFunctions.UNIQUE_FUNCTION, new ArrayList<String>());
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public Unique() from class datawave.query.language.functions.lucene.Unique


    @Override
    public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
        if (log.isTraceEnabled()) {
            log.trace("QueryIterator init()");
        }

        if (!validateOptions(new SourcedOptions<>(source, env, options))) {
            throw new IllegalArgumentException("Could not initialize QueryIterator with " + options.toString());
        }

        // We want to add in spoofed dataTypes for Aggregation/Evaluation to
        // ensure proper numeric evaluation.
        this.typeMetadata = new TypeMetadata(this.getTypeMetadata());
        typeMetadataWithNonIndexed = new TypeMetadata(this.typeMetadata);
        typeMetadataWithNonIndexed.addForAllIngestTypes(this.getNonIndexedDataTypeMap());

        // Parse the query
        try {

            script = JexlASTHelper.parseJexlQuery(this.getQuery());
            myEvaluationFunction = new JexlEvaluation(this.getQuery(), arithmetic);

        } catch (Exception e) {
            throw new IOException("Could not parse the JEXL query: '" + this.getQuery() + "'", e);
        }

        this.documentOptions = options;
        this.myEnvironment = env;

        if (gatherTimingDetails()) {
            trackingSpan = new MultiThreadedQuerySpan(getStatsdClient());
            this.source = new SourceTrackingIterator(trackingSpan, source);
        } else {
            this.source = source;
        }

        this.fiAggregator = new IdentityAggregator(getAllIndexOnlyFields(), getEvaluationFilter(), getEvaluationFilter() != null ? getEvaluationFilter()
                        .getMaxNextCount() : -1);

        if (isDebugMultithreadedSources()) {
            this.source = new SourceThreadTrackingIterator(this.source);
        }

        this.sourceForDeepCopies = this.source.deepCopy(this.myEnvironment);
    }

    @Override
    public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
        if (log.isTraceEnabled()) {
            log.trace("QueryIterator init()");
        }

        if (!validateOptions(new SourcedOptions<String,String>(source, env, options))) {
            throw new IllegalArgumentException("Could not initialize QueryIterator with " + options.toString());
        }

        // We want to add in spoofed dataTypes for Aggregation/Evaluation to
        // ensure proper numeric evaluation.
        this.typeMetadata = new TypeMetadata(this.getTypeMetadata());
        typeMetadataWithNonIndexed = new TypeMetadata(this.typeMetadata);
        typeMetadataWithNonIndexed.addForAllIngestTypes(this.getNonIndexedDataTypeMap());

        // Parse the query
        try {

            script = JexlASTHelper.parseJexlQuery(this.getQuery());
            myEvaluationFunction = new JexlEvaluation(this.getQuery(), arithmetic);

        } catch (Exception e) {
            throw new IOException("Could not parse the JEXL query: '" + this.getQuery() + "'", e);
        }

        this.documentOptions = options;
        this.myEnvironment = env;

        if (gatherTimingDetails()) {
            trackingSpan = new MultiThreadedQuerySpan(getStatsdClient());
            this.source = new SourceTrackingIterator(trackingSpan, source);
        } else {
            this.source = source;
        }

        this.fiAggregator = new IdentityAggregator(getAllIndexOnlyFields(), getEvaluationFilter(), getEvaluationFilter() != null ? getEvaluationFilter()
                        .getMaxNextCount() : -1);

        if (isDebugMultithreadedSources()) {
            this.source = new SourceThreadTrackingIterator(this.source);
        }

        this.sourceForDeepCopies = this.source.deepCopy(this.myEnvironment);
    }

Replace Generic With Diamond SourcedOptions<String,String> with SourcedOptions<> in method public init(source SortedKeyValueIterator<Key,Value>, options Map<String,String>, env IteratorEnvironment) : void from class datawave.query.iterator.QueryIterator


    protected Iterator<Entry<Key,Document>> getEvaluation(NestedQueryIterator<Key> documentSource, SortedKeyValueIterator<Key,Value> sourceDeepCopy,
                    Iterator<Entry<Key,Document>> documents, CompositeMetadata compositeMetadata, TypeMetadata typeMetadataForEval) {
        // Filter the Documents by testing them against the JEXL query
        if (!this.disableEvaluation) {

            JexlEvaluation jexlEvaluationFunction = getJexlEvaluation(documentSource);
            Collection<String> variables = null;
            if (null != documentSource && null != documentSource.getQuery()) {

                variables = VariableNameVisitor.parseQuery(jexlEvaluationFunction.parse(documentSource.getQuery()));
            } else {
                variables = VariableNameVisitor.parseQuery(jexlEvaluationFunction.parse(query));
            }

            final Iterator<Tuple2<Key,Document>> tupleItr = Iterators.transform(documents, new EntryToTuple<>());

            // get the function we use for the tf functionality. Note we are
            // getting an additional source deep copy for this function
            final Iterator<Tuple3<Key,Document,Map<String,Object>>> itrWithContext;
            if (this.isTermFrequenciesRequired()) {
                Function<Tuple2<Key,Document>,Tuple3<Key,Document,Map<String,Object>>> tfFunction;
                tfFunction = TFFactory.getFunction(getScript(documentSource), getContentExpansionFields(), getTermFrequencyFields(), this.getTypeMetadata(),
                                super.equality, getEvaluationFilter(), sourceDeepCopy.deepCopy(myEnvironment));

                itrWithContext = TraceIterators.transform(tupleItr, tfFunction, "Term Frequency Lookup");
            } else {
                itrWithContext = Iterators.transform(tupleItr, new EmptyContext<Key,Document,String,Object>());
            }

            final IndexOnlyContextCreator contextCreator = new IndexOnlyContextCreator(sourceDeepCopy, getDocumentRange(documentSource), typeMetadataForEval,
                            compositeMetadata, this, variables, QueryIterator.this);

            final Iterator<Tuple3<Key,Document,DatawaveJexlContext>> itrWithDatawaveJexlContext = Iterators.transform(itrWithContext, contextCreator);
            Iterator<Tuple3<Key,Document,DatawaveJexlContext>> matchedDocuments = statelessFilter(itrWithDatawaveJexlContext, jexlEvaluationFunction);
            if (log.isTraceEnabled()) {
                log.trace("arithmetic:" + arithmetic + " range:" + getDocumentRange(documentSource) + ", thread:" + Thread.currentThread());
            }
            return Iterators.transform(matchedDocuments, new TupleToEntry<Key,Document>());
        } else if (log.isTraceEnabled()) {
            log.trace("Evaluation is disabled, not instantiating Jexl evaluation logic");
        }
        return documents;
    }

    protected Iterator<Entry<Key,Document>> getEvaluation(NestedQueryIterator<Key> documentSource, SortedKeyValueIterator<Key,Value> sourceDeepCopy,
                    Iterator<Entry<Key,Document>> documents, CompositeMetadata compositeMetadata, TypeMetadata typeMetadataForEval) {
        // Filter the Documents by testing them against the JEXL query
        if (!this.disableEvaluation) {

            JexlEvaluation jexlEvaluationFunction = getJexlEvaluation(documentSource);
            Collection<String> variables = null;
            if (null != documentSource && null != documentSource.getQuery()) {

                variables = VariableNameVisitor.parseQuery(jexlEvaluationFunction.parse(documentSource.getQuery()));
            } else {
                variables = VariableNameVisitor.parseQuery(jexlEvaluationFunction.parse(query));
            }

            final Iterator<Tuple2<Key,Document>> tupleItr = Iterators.transform(documents, new EntryToTuple<Key,Document>());

            // get the function we use for the tf functionality. Note we are
            // getting an additional source deep copy for this function
            final Iterator<Tuple3<Key,Document,Map<String,Object>>> itrWithContext;
            if (this.isTermFrequenciesRequired()) {
                Function<Tuple2<Key,Document>,Tuple3<Key,Document,Map<String,Object>>> tfFunction;
                tfFunction = TFFactory.getFunction(getScript(documentSource), getContentExpansionFields(), getTermFrequencyFields(), this.getTypeMetadata(),
                                super.equality, getEvaluationFilter(), sourceDeepCopy.deepCopy(myEnvironment));

                itrWithContext = TraceIterators.transform(tupleItr, tfFunction, "Term Frequency Lookup");
            } else {
                itrWithContext = Iterators.transform(tupleItr, new EmptyContext<Key,Document,String,Object>());
            }

            final IndexOnlyContextCreator contextCreator = new IndexOnlyContextCreator(sourceDeepCopy, getDocumentRange(documentSource), typeMetadataForEval,
                            compositeMetadata, this, variables, QueryIterator.this);

            final Iterator<Tuple3<Key,Document,DatawaveJexlContext>> itrWithDatawaveJexlContext = Iterators.transform(itrWithContext, contextCreator);
            Iterator<Tuple3<Key,Document,DatawaveJexlContext>> matchedDocuments = statelessFilter(itrWithDatawaveJexlContext, jexlEvaluationFunction);
            if (log.isTraceEnabled()) {
                log.trace("arithmetic:" + arithmetic + " range:" + getDocumentRange(documentSource) + ", thread:" + Thread.currentThread());
            }
            return Iterators.transform(matchedDocuments, new TupleToEntry<Key,Document>());
        } else if (log.isTraceEnabled()) {
            log.trace("Evaluation is disabled, not instantiating Jexl evaluation logic");
        }
        return documents;
    }

Replace Generic With Diamond EntryToTuple<Key,Document> with EntryToTuple<> in method protected getEvaluation(documentSource NestedQueryIterator<Key>, sourceDeepCopy SortedKeyValueIterator<Key,Value>, documents Iterator<Entry<Key,Document>>, compositeMetadata CompositeMetadata, typeMetadataForEval TypeMetadata) : Iterator<Entry<Key,Document>> from class datawave.query.iterator.QueryIterator


    protected Iterator<Entry<Key,Document>> mapDocument(SortedKeyValueIterator<Key,Value> deepSourceCopy, Iterator<Entry<Key,Document>> documents,
                    CompositeMetadata compositeMetadata) {
        // now lets pull the data if we need to
        if (log.isTraceEnabled()) {
            log.trace("mapDocument " + fieldIndexSatisfiesQuery);
        }
        if (fieldIndexSatisfiesQuery) {
            final KeyToDocumentData docMapper = new KeyToDocumentData(deepSourceCopy, this.myEnvironment, this.documentOptions, super.equality,
                            getEvaluationFilter(), this.includeHierarchyFields, this.includeHierarchyFields);
            Iterator<Tuple2<Key,Document>> mappedDocuments = Iterators.transform(
                            documents,
                            new GetDocument(docMapper, new Aggregation(this.getTimeFilter(), typeMetadataWithNonIndexed, compositeMetadata, this
                                            .isIncludeGroupingContext(), this.includeRecordId, this.disableIndexOnlyDocuments(), getEvaluationFilter(),
                                            isTrackSizes())));

            Iterator<Entry<Key,Document>> retDocuments = Iterators.transform(mappedDocuments, new TupleToEntry<>());

            // Inject the document permutations if required
            if (!this.getDocumentPermutations().isEmpty()) {
                if (gatherTimingDetails()) {
                    retDocuments = Iterators.transform(retDocuments, new EvaluationTrackingFunction<>(QuerySpan.Stage.DocumentPermutation, trackingSpan,
                                    new DocumentPermutation.DocumentPermutationAggregation(this.getDocumentPermutations())));
                } else {
                    retDocuments = Iterators.transform(retDocuments, new DocumentPermutation.DocumentPermutationAggregation(this.getDocumentPermutations()));
                }
            }

            return retDocuments;

        }
        return documents;
    }

    protected Iterator<Entry<Key,Document>> mapDocument(SortedKeyValueIterator<Key,Value> deepSourceCopy, Iterator<Entry<Key,Document>> documents,
                    CompositeMetadata compositeMetadata) {
        // now lets pull the data if we need to
        if (log.isTraceEnabled()) {
            log.trace("mapDocument " + fieldIndexSatisfiesQuery);
        }
        if (fieldIndexSatisfiesQuery) {
            final KeyToDocumentData docMapper = new KeyToDocumentData(deepSourceCopy, this.myEnvironment, this.documentOptions, super.equality,
                            getEvaluationFilter(), this.includeHierarchyFields, this.includeHierarchyFields);
            Iterator<Tuple2<Key,Document>> mappedDocuments = Iterators.transform(
                            documents,
                            new GetDocument(docMapper, new Aggregation(this.getTimeFilter(), typeMetadataWithNonIndexed, compositeMetadata, this
                                            .isIncludeGroupingContext(), this.includeRecordId, this.disableIndexOnlyDocuments(), getEvaluationFilter(),
                                            isTrackSizes())));

            Iterator<Entry<Key,Document>> retDocuments = Iterators.transform(mappedDocuments, new TupleToEntry<Key,Document>());

            // Inject the document permutations if required
            if (!this.getDocumentPermutations().isEmpty()) {
                if (gatherTimingDetails()) {
                    retDocuments = Iterators.transform(retDocuments, new EvaluationTrackingFunction<>(QuerySpan.Stage.DocumentPermutation, trackingSpan,
                                    new DocumentPermutation.DocumentPermutationAggregation(this.getDocumentPermutations())));
                } else {
                    retDocuments = Iterators.transform(retDocuments, new DocumentPermutation.DocumentPermutationAggregation(this.getDocumentPermutations()));
                }
            }

            return retDocuments;

        }
        return documents;
    }

Replace Generic With Diamond TupleToEntry<Key,Document> with TupleToEntry<> in method protected mapDocument(deepSourceCopy SortedKeyValueIterator<Key,Value>, documents Iterator<Entry<Key,Document>>, compositeMetadata CompositeMetadata) : Iterator<Entry<Key,Document>> from class datawave.query.iterator.QueryIterator


    public Options() {
        super(QueryFunctions.OPTIONS_FUNCTION, new ArrayList<>());
    }

    public Options() {
        super("options", new ArrayList<String>());
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public Options() from class datawave.query.language.functions.jexl.Options


        public Iterable<Pair<KeyExtent,Location>> getLocationProvider() {
            return Iterables.transform(tabletLocs.entrySet(), input -> new Pair<>(input.getKey(), new Location(input.getValue())));
        }

        public Iterable<Pair<KeyExtent,Location>> getLocationProvider() {
            return Iterables.transform(tabletLocs.entrySet(), new Function<Entry<KeyExtent,TServerInstance>,Pair<KeyExtent,Location>>() {
                @Override
                public Pair<KeyExtent,Location> apply(Entry<KeyExtent,TServerInstance> input) {
                    return new Pair<>(input.getKey(), new Location(input.getValue()));
                }
            });
        }

Replace Anonymous With Lambda datawave.ingest.table.balancer.ShardedTableTabletBalancerTest.TestTServers.getLocationProvider.transform.new Function<Entry<KeyExtent,TServerInstance>,Pair<KeyExtent,Location>> with input -> new Pair<>(input.getKey(),new Location(input.getValue())) in method public getLocationProvider() : Iterable<Pair<KeyExtent,Location>> from class datawave.ingest.table.balancer.ShardedTableTabletBalancerTest.TestTServers


    @Override
    public ListenableFuture<V> reload(final K key, final V oldValue) {

        if (log.isTraceEnabled())
            log.trace("Reload the cache");

        ListenableFutureTask<V> task = null;
        if (!lazy) {
            if (log.isTraceEnabled())
                log.trace("Reloading synchronously");
            try {
                build(null);

                return Futures.immediateCheckedFuture(load(key));

            } catch (Exception e) {
                log.error(e);
            }
        } else {

            task = ListenableFutureTask.create(() -> {
                build(null);
                return load(key);
            });

            executor.execute(task);
        }

        return task;

    }

    @Override
    public ListenableFuture<V> reload(final K key, final V oldValue) {

        if (log.isTraceEnabled())
            log.trace("Reload the cache");

        ListenableFutureTask<V> task = null;
        if (!lazy) {
            if (log.isTraceEnabled())
                log.trace("Reloading synchronously");
            try {
                build(null);

                return Futures.immediateCheckedFuture(load(key));

            } catch (Exception e) {
                log.error(e);
            }
        } else {

            task = ListenableFutureTask.create(new Callable<V>() {

                @Override
                public V call() throws Exception {
                    build(null);
                    return load(key);
                }
            });

            executor.execute(task);
        }

        return task;

    }

Replace Anonymous With Lambda datawave.ingest.util.cache.Loader.reload.create.new Callable<V> with () -> {build(null); in method public reload(key K, oldValue V) : ListenableFuture<V> from class datawave.ingest.util.cache.Loader


    /**
     * This method instantiates the the necessary implementations of the {@code Filter} interface, as they are defined in the configuration file specified by
     * {@code this.filename}.
     *
     * @throws IllegalArgumentException
     *             if there is an error in the configuration file
     * @throws IOException
     */
    private void initFilterRules() throws IllegalArgumentException, IOException {
        // filename
        if (null == ruleCache) {
            synchronized (ConfigurableAgeOffFilter.class) {
                if (null == ruleCache) {
                    UPDATE_INTERVAL_MS = getLongProperty(UPDATE_INTERVAL_MS_PROP, DEFAULT_UPDATE_INTERVAL_MS); // 5 ms
                    EXPIRATION_INTERVAL_MS = getLongProperty(EXPIRATION_INTERVAL_MS_PROP, DEFAULT_EXPIRATION_INTERVAL_MS); // 1 hour
                    ruleCache = CacheBuilder.newBuilder().refreshAfterWrite(UPDATE_INTERVAL_MS, TimeUnit.MILLISECONDS)
                                    .expireAfterAccess(EXPIRATION_INTERVAL_MS, TimeUnit.MILLISECONDS).build(new ReloadableCacheBuilder());
                    SimpleTimer.getInstance(AccumuloConfiguration.getDefaultConfiguration()).schedule(
                                    () -> {
                                        try {
                                            long interval = getLongProperty(UPDATE_INTERVAL_MS_PROP, DEFAULT_UPDATE_INTERVAL_MS);
                                            long expiration = getLongProperty(EXPIRATION_INTERVAL_MS_PROP, DEFAULT_EXPIRATION_INTERVAL_MS);
                                            if (UPDATE_INTERVAL_MS != interval || EXPIRATION_INTERVAL_MS != expiration) {
                                                log.info("Changing " + UPDATE_INTERVAL_MS_PROP + " to " + interval);
                                                UPDATE_INTERVAL_MS = interval;
                                                log.info("Changing " + EXPIRATION_INTERVAL_MS_PROP + " to " + expiration);
                                                EXPIRATION_INTERVAL_MS = expiration;
                                                ruleCache = CacheBuilder.newBuilder().refreshAfterWrite(UPDATE_INTERVAL_MS, TimeUnit.MILLISECONDS)
                                                                .expireAfterAccess(EXPIRATION_INTERVAL_MS, TimeUnit.MILLISECONDS)
                                                                .build(new ReloadableCacheBuilder());
                                            }
                                        } catch (Throwable t) {
                                            log.error(t, t);
                                        }
                                    }, 1000, 10 * 1000);
                }
            }
        }

        Path filePath = new Path(filename);
        if (null == fs) {
            synchronized (ConfigurableAgeOffFilter.class) {
                if (null == fs) {
                    if (log.isTraceEnabled()) {
                        log.trace("Setting FileSystem reference");
                    }
                    fs = filePath.getFileSystem(new Configuration());
                }
            }
        } else {
            if (log.isTraceEnabled()) {
                log.trace("Reusing file system reference.");
            }
        }
        FileRuleWatcher watcherKey = new FileRuleWatcher(fs, filePath, 1);

        copyRules(watcherKey);

    }

    /**
     * This method instantiates the the necessary implementations of the {@code Filter} interface, as they are defined in the configuration file specified by
     * {@code this.filename}.
     *
     * @throws IllegalArgumentException
     *             if there is an error in the configuration file
     * @throws IOException
     */
    private void initFilterRules() throws IllegalArgumentException, IOException {
        // filename
        if (null == ruleCache) {
            synchronized (ConfigurableAgeOffFilter.class) {
                if (null == ruleCache) {
                    UPDATE_INTERVAL_MS = getLongProperty(UPDATE_INTERVAL_MS_PROP, DEFAULT_UPDATE_INTERVAL_MS); // 5 ms
                    EXPIRATION_INTERVAL_MS = getLongProperty(EXPIRATION_INTERVAL_MS_PROP, DEFAULT_EXPIRATION_INTERVAL_MS); // 1 hour
                    ruleCache = CacheBuilder.newBuilder().refreshAfterWrite(UPDATE_INTERVAL_MS, TimeUnit.MILLISECONDS)
                                    .expireAfterAccess(EXPIRATION_INTERVAL_MS, TimeUnit.MILLISECONDS).build(new ReloadableCacheBuilder());
                    SimpleTimer.getInstance(AccumuloConfiguration.getDefaultConfiguration()).schedule(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                long interval = getLongProperty(UPDATE_INTERVAL_MS_PROP, DEFAULT_UPDATE_INTERVAL_MS);
                                long expiration = getLongProperty(EXPIRATION_INTERVAL_MS_PROP, DEFAULT_EXPIRATION_INTERVAL_MS);
                                if (UPDATE_INTERVAL_MS != interval || EXPIRATION_INTERVAL_MS != expiration) {
                                    log.info("Changing " + UPDATE_INTERVAL_MS_PROP + " to " + interval);
                                    UPDATE_INTERVAL_MS = interval;
                                    log.info("Changing " + EXPIRATION_INTERVAL_MS_PROP + " to " + expiration);
                                    EXPIRATION_INTERVAL_MS = expiration;
                                    ruleCache = CacheBuilder.newBuilder().refreshAfterWrite(UPDATE_INTERVAL_MS, TimeUnit.MILLISECONDS)
                                                    .expireAfterAccess(EXPIRATION_INTERVAL_MS, TimeUnit.MILLISECONDS).build(new ReloadableCacheBuilder());
                                }
                            } catch (Throwable t) {
                                log.error(t, t);
                            }
                        }

                    }, 1000, 10 * 1000);
                }
            }
        }

        Path filePath = new Path(filename);
        if (null == fs) {
            synchronized (ConfigurableAgeOffFilter.class) {
                if (null == fs) {
                    if (log.isTraceEnabled()) {
                        log.trace("Setting FileSystem reference");
                    }
                    fs = filePath.getFileSystem(new Configuration());
                }
            }
        } else {
            if (log.isTraceEnabled()) {
                log.trace("Reusing file system reference.");
            }
        }
        FileRuleWatcher watcherKey = new FileRuleWatcher(fs, filePath, 1);

        copyRules(watcherKey);

    }

Replace Anonymous With Lambda datawave.iterators.filter.ConfigurableAgeOffFilter.initFilterRules.schedule.new Runnable with () -> {trylong interval=getLongProperty(UPDATE_INTERVAL_MS_PROP,DEFAULT_UPDATE_INTERVAL_MS); in method private initFilterRules() : void from class datawave.iterators.filter.ConfigurableAgeOffFilter


    Iterable<Entry<String,NormalizedContentInterface>> getMatches(final Matcher matcher, Multimap<String,NormalizedContentInterface> fields) {
        return Iterables.filter(fields.entries(), input -> {
            // check to see if entry key matches the supplied matcher
                        return matcher.reset(input.getKey()).matches();
                    });

    }

    Iterable<Entry<String,NormalizedContentInterface>> getMatches(final Matcher matcher, Multimap<String,NormalizedContentInterface> fields) {
        return Iterables.filter(fields.entries(), new Predicate<Map.Entry<String,NormalizedContentInterface>>() {
            @Override
            public boolean apply(Entry<String,NormalizedContentInterface> input) {
                // check to see if entry key matches the supplied matcher
                return matcher.reset(input.getKey()).matches();
            }
        });

    }

Replace Anonymous With Lambda datawave.ingest.mapreduce.handler.summary.MetricsSummaryFormatter.getMatches.filter.new Predicate<Map.Entry<String,NormalizedContentInterface>> with input -> {return matcher.reset(input.getKey()).matches(); in method package getMatches(matcher Matcher, fields Multimap<String,NormalizedContentInterface>) : Iterable<Entry<String,NormalizedContentInterface>> from class datawave.ingest.mapreduce.handler.summary.MetricsSummaryFormatter


    public BulkIngestMapFileLoader(String workDir, String jobDirPattern, String instanceName, String zooKeepers, Credentials credentials, URI seqFileHdfs,
                    URI srcHdfs, URI destHdfs, String jobtracker, Map<String,Integer> tablePriorities, Configuration conf, int shutdownPort, int numHdfsThreads) {
        this.conf = conf;
        this.tablePriorities = tablePriorities;
        this.workDir = new Path(workDir);
        this.jobDirPattern = jobDirPattern;
        this.instanceName = instanceName;
        this.zooKeepers = zooKeepers;
        this.credentials = credentials;
        this.seqFileHdfs = seqFileHdfs;
        this.srcHdfs = srcHdfs;
        this.destHdfs = destHdfs;
        this.jobtracker = jobtracker;
        this.running = true;
        this.executor = Executors.newFixedThreadPool(numHdfsThreads > 0 ? numHdfsThreads : 1);
        try {
            if (shutdownPort > 0) {
                final ServerSocket serverSocket = new ServerSocket(shutdownPort);
                Runnable shutdownListener = () -> listenForShutdownCommand(serverSocket);
                Thread t = new Thread(shutdownListener, "shutdown-listener");
                t.setDaemon(true);
                t.start();
            }
        } catch (IOException e) {
            log.error("Unable to create shutdown listener socket. Exiting.", e);
        }
    }

    public BulkIngestMapFileLoader(String workDir, String jobDirPattern, String instanceName, String zooKeepers, Credentials credentials, URI seqFileHdfs,
                    URI srcHdfs, URI destHdfs, String jobtracker, Map<String,Integer> tablePriorities, Configuration conf, int shutdownPort, int numHdfsThreads) {
        this.conf = conf;
        this.tablePriorities = tablePriorities;
        this.workDir = new Path(workDir);
        this.jobDirPattern = jobDirPattern;
        this.instanceName = instanceName;
        this.zooKeepers = zooKeepers;
        this.credentials = credentials;
        this.seqFileHdfs = seqFileHdfs;
        this.srcHdfs = srcHdfs;
        this.destHdfs = destHdfs;
        this.jobtracker = jobtracker;
        this.running = true;
        this.executor = Executors.newFixedThreadPool(numHdfsThreads > 0 ? numHdfsThreads : 1);
        try {
            if (shutdownPort > 0) {
                final ServerSocket serverSocket = new ServerSocket(shutdownPort);
                Runnable shutdownListener = new Runnable() {
                    @Override
                    public void run() {
                        listenForShutdownCommand(serverSocket);
                    }
                };
                Thread t = new Thread(shutdownListener, "shutdown-listener");
                t.setDaemon(true);
                t.start();
            }
        } catch (IOException e) {
            log.error("Unable to create shutdown listener socket. Exiting.", e);
        }
    }

Replace Anonymous With Lambda datawave.ingest.mapreduce.job.BulkIngestMapFileLoader.BulkIngestMapFileLoader.shutdownListener.new Runnable with () -> listenForShutdownCommand(serverSocket) in method public BulkIngestMapFileLoader(workDir String, jobDirPattern String, instanceName String, zooKeepers String, credentials Credentials, seqFileHdfs URI, srcHdfs URI, destHdfs URI, jobtracker String, tablePriorities Map<String,Integer>, conf Configuration, shutdownPort int, numHdfsThreads int) from class datawave.ingest.mapreduce.job.BulkIngestMapFileLoader


    /**
     * Gets a list of job directories that are marked as completed. That is, these are job directories for which the MapReduce jobs have completed and there are
     * map files ready to be loaded.
     */
    private Path[] getJobDirectories() throws IOException {
        log.debug("Checking for completed job directories.");
        FileSystem fs = getFileSystem(srcHdfs);
        FileStatus[] files = fs.globStatus(new Path(workDir, jobDirPattern + '/' + COMPLETE_FILE_MARKER));
        Path[] jobDirectories;
        if (files != null && files.length > 0) {
            final int order = (FIFO ? 1 : -1);
            Arrays.sort(files, (o1, o2) -> {
                long m1 = o1.getModificationTime();
                long m2 = o2.getModificationTime();
                return order * ((m1 < m2) ? -1 : ((m1 > m2) ? 1 : 0));
            });
            jobDirectories = new Path[Math.min(MAX_DIRECTORIES, files.length)];
            for (int i = 0; i < jobDirectories.length; i++) {
                jobDirectories[i] = files[i].getPath().getParent();
            }
        } else {
            jobDirectories = new Path[0];
        }
        log.debug("Completed job directories: " + Arrays.toString(jobDirectories));
        return jobDirectories;
    }

    /**
     * Gets a list of job directories that are marked as completed. That is, these are job directories for which the MapReduce jobs have completed and there are
     * map files ready to be loaded.
     */
    private Path[] getJobDirectories() throws IOException {
        log.debug("Checking for completed job directories.");
        FileSystem fs = getFileSystem(srcHdfs);
        FileStatus[] files = fs.globStatus(new Path(workDir, jobDirPattern + '/' + COMPLETE_FILE_MARKER));
        Path[] jobDirectories;
        if (files != null && files.length > 0) {
            final int order = (FIFO ? 1 : -1);
            Arrays.sort(files, new Comparator<FileStatus>() {
                @Override
                public int compare(FileStatus o1, FileStatus o2) {
                    long m1 = o1.getModificationTime();
                    long m2 = o2.getModificationTime();
                    return order * ((m1 < m2) ? -1 : ((m1 > m2) ? 1 : 0));
                }
            });
            jobDirectories = new Path[Math.min(MAX_DIRECTORIES, files.length)];
            for (int i = 0; i < jobDirectories.length; i++) {
                jobDirectories[i] = files[i].getPath().getParent();
            }
        } else {
            jobDirectories = new Path[0];
        }
        log.debug("Completed job directories: " + Arrays.toString(jobDirectories));
        return jobDirectories;
    }

Replace Anonymous With Lambda datawave.ingest.mapreduce.job.BulkIngestMapFileLoader.getJobDirectories.sort.new Comparator<FileStatus> with (o1, o2) -> {long m1=o1.getModificationTime(); in method private getJobDirectories() : Path[] from class datawave.ingest.mapreduce.job.BulkIngestMapFileLoader


    /**
     * Brings all map files in {@code mapFilesDir} online in accumulo. Note that {@code mapFilesDir} is assumed to have subdirectories that are the names of the
     * tables for which map files are to be loaded. Under those directories should be "part-XXXXX" directories which in turn contain the map/index files.
     */
    public void bringMapFilesOnline(Path mapFilesDir) throws IOException, AccumuloException, AccumuloSecurityException, TableNotFoundException {
        log.info("Bringing all mapFiles under " + mapFilesDir + " online.");

        // By now the map files should be on the local filesystem
        FileSystem fs = getFileSystem(destHdfs);

        Instance instance = new ZooKeeperInstance(ClientConfiguration.loadDefault().withInstance(instanceName).withZkHosts(zooKeepers));
        TableOperations tops = instance.getConnector(credentials.getPrincipal(), credentials.getToken()).tableOperations();
        SortedMap<String,String> tableIds = Tables.getNameToIdMap(instance);
        FileStatus[] tableDirs = fs.globStatus(new Path(mapFilesDir, "*"));

        // sort the table dirs in priority order based on the configuration
        Arrays.sort(tableDirs, (o1, o2) -> {
            Integer p1 = tablePriorities.get(o1.getPath().getName());
            Integer p2 = tablePriorities.get(o2.getPath().getName());
            if (p1 == null) {
                if (p2 == null) {
                    return o1.getPath().getName().compareTo(o2.getPath().getName());
                } else {
                    return 1;
                }
            } else {
                if (p2 == null) {
                    return -1;
                } else {
                    return p1.compareTo(p2);
                }
            }
        });

        // now load the tables in the prioritized order, concurrently loading those with the same priority
        Integer priority = null;
        Stack<ImportRunnable> imports = new Stack<>();
        Map<String,Path> tableNames = new HashMap<>();
        for (FileStatus stat : tableDirs) {
            Path tableDir = stat.getPath();
            String tableName = tableDir.getName();

            if (!tableIds.containsKey(tableName)) {
                log.debug("Skipping " + tableDir + " since it is not a accumulo table directory.");
                continue;
            }

            if (tableNames.containsKey(tableName)) {
                if (tableNames.get(tableName).equals(tableDir)) {
                    log.warn("Skipping " + tableDir + " since we already processed " + tableName + " under " + tableNames.get(tableName));
                    continue;
                } else {
                    log.error("We got two different paths for " + tableName + ": " + tableNames.get(tableName) + " and " + tableDir);
                    throw new IOException("We got two different paths for " + tableName + ": " + tableNames.get(tableName) + " and " + tableDir);
                }
            }
            tableNames.put(tableName, tableDir);

            Integer newPriority = tablePriorities.get(stat.getPath().getName());
            if (!Objects.equal(priority, newPriority)) {
                Exception e = null;
                while (!imports.isEmpty()) {
                    ImportRunnable importTask = imports.pop();
                    try {
                        importTask.waitForCompletion();
                        if (e == null)
                            e = importTask.getException();
                    } catch (InterruptedException interrupted) {
                        // this task was interrupted, wait for the others and then terminate
                        if (e == null)
                            e = interrupted;
                    }
                }
                // if an exception occurred during processing, terminate
                if (e != null)
                    throw new IOException(e);

                priority = tablePriorities.get(stat.getPath().getName());
            }
            imports.push(startImport(mapFilesDir, tableName, tableDir, tops));
        }

        Exception e = null;
        while (!imports.isEmpty()) {
            ImportRunnable importTask = imports.pop();
            try {
                importTask.waitForCompletion();
                if (e == null)
                    e = importTask.getException();
            } catch (InterruptedException interrupted) {
                // this task was interrupted, wait for the others and then terminate
                if (e == null)
                    e = interrupted;
            }
        }
        // if an exception occurred during processing, terminate
        if (e != null)
            throw new IOException(e);
    }

    /**
     * Brings all map files in {@code mapFilesDir} online in accumulo. Note that {@code mapFilesDir} is assumed to have subdirectories that are the names of the
     * tables for which map files are to be loaded. Under those directories should be "part-XXXXX" directories which in turn contain the map/index files.
     */
    public void bringMapFilesOnline(Path mapFilesDir) throws IOException, AccumuloException, AccumuloSecurityException, TableNotFoundException {
        log.info("Bringing all mapFiles under " + mapFilesDir + " online.");

        // By now the map files should be on the local filesystem
        FileSystem fs = getFileSystem(destHdfs);

        Instance instance = new ZooKeeperInstance(ClientConfiguration.loadDefault().withInstance(instanceName).withZkHosts(zooKeepers));
        TableOperations tops = instance.getConnector(credentials.getPrincipal(), credentials.getToken()).tableOperations();
        SortedMap<String,String> tableIds = Tables.getNameToIdMap(instance);
        FileStatus[] tableDirs = fs.globStatus(new Path(mapFilesDir, "*"));

        // sort the table dirs in priority order based on the configuration
        Arrays.sort(tableDirs, new Comparator<FileStatus>() {
            @Override
            public int compare(FileStatus o1, FileStatus o2) {
                Integer p1 = tablePriorities.get(o1.getPath().getName());
                Integer p2 = tablePriorities.get(o2.getPath().getName());
                if (p1 == null) {
                    if (p2 == null) {
                        return o1.getPath().getName().compareTo(o2.getPath().getName());
                    } else {
                        return 1;
                    }
                } else {
                    if (p2 == null) {
                        return -1;
                    } else {
                        return p1.compareTo(p2);
                    }
                }
            }
        });

        // now load the tables in the prioritized order, concurrently loading those with the same priority
        Integer priority = null;
        Stack<ImportRunnable> imports = new Stack<>();
        Map<String,Path> tableNames = new HashMap<>();
        for (FileStatus stat : tableDirs) {
            Path tableDir = stat.getPath();
            String tableName = tableDir.getName();

            if (!tableIds.containsKey(tableName)) {
                log.debug("Skipping " + tableDir + " since it is not a accumulo table directory.");
                continue;
            }

            if (tableNames.containsKey(tableName)) {
                if (tableNames.get(tableName).equals(tableDir)) {
                    log.warn("Skipping " + tableDir + " since we already processed " + tableName + " under " + tableNames.get(tableName));
                    continue;
                } else {
                    log.error("We got two different paths for " + tableName + ": " + tableNames.get(tableName) + " and " + tableDir);
                    throw new IOException("We got two different paths for " + tableName + ": " + tableNames.get(tableName) + " and " + tableDir);
                }
            }
            tableNames.put(tableName, tableDir);

            Integer newPriority = tablePriorities.get(stat.getPath().getName());
            if (!Objects.equal(priority, newPriority)) {
                Exception e = null;
                while (!imports.isEmpty()) {
                    ImportRunnable importTask = imports.pop();
                    try {
                        importTask.waitForCompletion();
                        if (e == null)
                            e = importTask.getException();
                    } catch (InterruptedException interrupted) {
                        // this task was interrupted, wait for the others and then terminate
                        if (e == null)
                            e = interrupted;
                    }
                }
                // if an exception occurred during processing, terminate
                if (e != null)
                    throw new IOException(e);

                priority = tablePriorities.get(stat.getPath().getName());
            }
            imports.push(startImport(mapFilesDir, tableName, tableDir, tops));
        }

        Exception e = null;
        while (!imports.isEmpty()) {
            ImportRunnable importTask = imports.pop();
            try {
                importTask.waitForCompletion();
                if (e == null)
                    e = importTask.getException();
            } catch (InterruptedException interrupted) {
                // this task was interrupted, wait for the others and then terminate
                if (e == null)
                    e = interrupted;
            }
        }
        // if an exception occurred during processing, terminate
        if (e != null)
            throw new IOException(e);
    }

Replace Anonymous With Lambda datawave.ingest.mapreduce.job.BulkIngestMapFileLoader.bringMapFilesOnline.sort.new Comparator<FileStatus> with (o1, o2) -> {Integer p1=tablePriorities.get(o1.getPath().getName()); in method public bringMapFilesOnline(mapFilesDir Path) : void from class datawave.ingest.mapreduce.job.BulkIngestMapFileLoader


    public void markSourceFilesLoaded(Path jobDirectory) throws IOException {
        ArrayList<String> files = new ArrayList<>();

        final FileSystem destFs = getFileSystem(destHdfs);
        BufferedReader rdr = new BufferedReader(new InputStreamReader(destFs.open(new Path(jobDirectory, INPUT_FILES_MARKER))));
        String line;
        while ((line = rdr.readLine()) != null) {
            files.add(line);
        }
        rdr.close();

        final FileSystem sourceFs = getFileSystem(seqFileHdfs);
        List<Callable<Boolean>> renameCallables = Lists.newArrayList();

        for (final String file : files) {

            renameCallables.add(() -> {
                if (file.contains("/flagged/")) {
                    Path dst = new Path(file.replaceFirst("/flagged/", "/loaded/"));
                    boolean mkdirs = sourceFs.mkdirs(dst.getParent());
                    if (mkdirs) {
                        boolean renamed = false;
                        try {
                            renamed = sourceFs.rename(new Path(file), dst);
                        } catch (Exception e) {
                            log.warn("Exception renaming " + file + " to " + dst, e);
                            renamed = false;
                        }
                        if (!renamed) {
                            // if the file is already in loaded and not in flagged,
                            // then we do not need to fail here
                            boolean flaggedExists = sourceFs.exists(new Path(file));
                            boolean loadedExists = sourceFs.exists(dst);
                            if (flaggedExists || !loadedExists) {
                                throw new IOException("Unable to rename " + file + " (exists=" + flaggedExists + ") to " + dst + " (exists=" + loadedExists
                                                + ")");
                            } else {
                                log.warn("File was already moved to loaded: " + dst);
                                renamed = true;
                            }
                        }
                        return Boolean.valueOf(renamed);
                    } else {
                        throw new IOException("Unable to create parent dir " + dst.getParent());
                    }

                }
                return Boolean.valueOf(false);
            });
        }
        try {
            log.info("Marking " + renameCallables.size() + " sequence files from flagged to loaded");

            if (renameCallables.size() > 0) {
                List<Future<Boolean>> execResults = executor.invokeAll(renameCallables);

                for (Future<Boolean> future : execResults) {
                    if (future.get() == null)
                        throw new IOException("Error while attempting to mark job as loaded");
                }
            }

        } catch (InterruptedException e) {
            if (null != e.getCause())
                throw new IOException(e.getCause().getMessage());
            else
                throw new IOException(e);
        } catch (ExecutionException e) {
            if (null != e.getCause())
                throw new IOException(e.getCause().getMessage());
            else
                throw new IOException(e);
        }
    }

    public void markSourceFilesLoaded(Path jobDirectory) throws IOException {
        ArrayList<String> files = new ArrayList<>();

        final FileSystem destFs = getFileSystem(destHdfs);
        BufferedReader rdr = new BufferedReader(new InputStreamReader(destFs.open(new Path(jobDirectory, INPUT_FILES_MARKER))));
        String line;
        while ((line = rdr.readLine()) != null) {
            files.add(line);
        }
        rdr.close();

        final FileSystem sourceFs = getFileSystem(seqFileHdfs);
        List<Callable<Boolean>> renameCallables = Lists.newArrayList();

        for (final String file : files) {

            renameCallables.add(new Callable<Boolean>() {
                @Override
                public Boolean call() throws IOException {
                    if (file.contains("/flagged/")) {
                        Path dst = new Path(file.replaceFirst("/flagged/", "/loaded/"));
                        boolean mkdirs = sourceFs.mkdirs(dst.getParent());
                        if (mkdirs) {
                            boolean renamed = false;
                            try {
                                renamed = sourceFs.rename(new Path(file), dst);
                            } catch (Exception e) {
                                log.warn("Exception renaming " + file + " to " + dst, e);
                                renamed = false;
                            }
                            if (!renamed) {
                                // if the file is already in loaded and not in flagged,
                                // then we do not need to fail here
                                boolean flaggedExists = sourceFs.exists(new Path(file));
                                boolean loadedExists = sourceFs.exists(dst);
                                if (flaggedExists || !loadedExists) {
                                    throw new IOException("Unable to rename " + file + " (exists=" + flaggedExists + ") to " + dst + " (exists=" + loadedExists
                                                    + ")");
                                } else {
                                    log.warn("File was already moved to loaded: " + dst);
                                    renamed = true;
                                }
                            }
                            return Boolean.valueOf(renamed);
                        } else {
                            throw new IOException("Unable to create parent dir " + dst.getParent());
                        }

                    }
                    return Boolean.valueOf(false);
                }
            });
        }
        try {
            log.info("Marking " + renameCallables.size() + " sequence files from flagged to loaded");

            if (renameCallables.size() > 0) {
                List<Future<Boolean>> execResults = executor.invokeAll(renameCallables);

                for (Future<Boolean> future : execResults) {
                    if (future.get() == null)
                        throw new IOException("Error while attempting to mark job as loaded");
                }
            }

        } catch (InterruptedException e) {
            if (null != e.getCause())
                throw new IOException(e.getCause().getMessage());
            else
                throw new IOException(e);
        } catch (ExecutionException e) {
            if (null != e.getCause())
                throw new IOException(e.getCause().getMessage());
            else
                throw new IOException(e);
        }
    }

Replace Anonymous With Lambda datawave.ingest.mapreduce.job.BulkIngestMapFileLoader.markSourceFilesLoaded.add.new Callable<Boolean> with () -> {if(file.contains("/flagged/")){Path dst=new Path(file.replaceFirst("/flagged/","/loaded/")); in method public markSourceFilesLoaded(jobDirectory Path) : void from class datawave.ingest.mapreduce.job.BulkIngestMapFileLoader