Example usage for java.util Set clear

List of usage examples for java.util Set clear

Introduction

In this page you can find the example usage for java.util Set clear.

Prototype

void clear();

Source Link

Document

Removes all of the elements from this set (optional operation).

Usage

From source file:fr.landel.utils.assertor.AssertorIterableTest.java

/**
 * Test method for {@link AssertorIterable#contains}.
 * //from ww w. j a va 2s. c  o  m
 * @throws IOException
 *             On contain
 */
@Test
public void testDoesNotContain() throws IOException {
    final String el1 = "element1";
    final String el2 = "element2";

    final Set<String> set = new HashSet<>();
    set.add(el1);

    Assertor.that(set).not().contains(el2).orElseThrow("iterable contains the element %s*");
    Assertor.that(set).not().contains((String) null).orElseThrow();
    Assertor.that(set, EnumAnalysisMode.STREAM).not().contains(el2)
            .orElseThrow("iterable contains the element %s*");
    Assertor.that(set, EnumAnalysisMode.STREAM).not().contains((String) null).orElseThrow();
    Assertor.that(set, EnumAnalysisMode.PARALLEL).not().contains(el2)
            .orElseThrow("iterable contains the element %s*");
    Assertor.that(set, EnumAnalysisMode.PARALLEL).not().contains((String) null).orElseThrow();

    assertException(() -> {
        Assertor.that(set).not().contains(el1).orElseThrow();
        fail(ERROR);
    }, IllegalArgumentException.class, "the iterable '[element1]' should NOT contain the object 'element1'");

    assertException(() -> {
        Assertor.that(set).not().contains(el1).orElseThrow("iterable contains the element %2$s*");
        fail(ERROR);
    }, IllegalArgumentException.class, "iterable contains the element " + el1);

    assertException(() -> {
        Assertor.that(set).not().contains(el1).orElseThrow(new IOException(), false);
        fail(ERROR);
    }, IOException.class);

    set.clear();

    assertException(() -> {
        Assertor.that((Iterable<String>) null).not().contains(el1).orElseThrow();
        fail(ERROR);
    }, IllegalArgumentException.class, "the iterable cannot be null or empty");
}

From source file:org.waarp.common.filemonitor.FileMonitor.java

/**
 * /*  ww w  . j a  v a 2  s. c  om*/
 * @return the status (updated only) in JSON format
 */
public String getStatus() {
    Set<String> removedFileItems = null;
    ConcurrentHashMap<String, FileItem> newFileItems = new ConcurrentHashMap<String, FileMonitor.FileItem>();
    if (!lastFileItems.isEmpty()) {
        removedFileItems = lastFileItems.keySet();
        removedFileItems.removeAll(fileItems.keySet());
        for (Entry<String, FileItem> key : fileItems.entrySet()) {
            if (!key.getValue().isStrictlySame(lastFileItems.get(key.getKey()))) {
                newFileItems.put(key.getKey(), key.getValue());
            }
        }
    } else {
        for (Entry<String, FileItem> key : fileItems.entrySet()) {
            newFileItems.put(key.getKey(), key.getValue());
        }
    }
    FileMonitorInformation fileMonitorInformation = new FileMonitorInformation(name, newFileItems,
            removedFileItems, directories, stopFile, statusFile, elapseTime, scanSubDir, globalok, globalerror,
            todayok, todayerror);
    for (Entry<String, FileItem> key : fileItems.entrySet()) {
        FileItem clone = key.getValue().clone();
        lastFileItems.put(key.getKey(), clone);
    }
    createChkFile();
    String status = JsonHandler.writeAsString(fileMonitorInformation);
    if (removedFileItems != null) {
        removedFileItems.clear();
    }
    newFileItems.clear();
    return status;
}

From source file:com.hs.mail.mailet.RemoteDelivery.java

/**
 * For this message, we take the list of recipients, organize these into
 * distinct servers, and deliver the message for each of these servers.
 *//*from w  ww.  j  a v a2s . com*/
public void service(Set<Recipient> recipients, SmtpMessage message) throws MessagingException {
    // Organize the recipients into distinct servers (name made case insensitive)
    Hashtable<String, Collection<Recipient>> targets = new Hashtable<String, Collection<Recipient>>();
    for (Recipient recipient : recipients) {
        String targetServer = recipient.getHost().toLowerCase(Locale.US);
        if (!Config.isLocal(targetServer)) {
            String key = (null == gateway) ? targetServer : gateway;
            Collection<Recipient> temp = targets.get(key);
            if (temp == null) {
                temp = new ArrayList<Recipient>();
                targets.put(key, temp);
            }
            temp.add(recipient);
        }
    }

    if (targets.isEmpty()) {
        return;
    }

    // We have the recipients organized into distinct servers
    List<Recipient> undelivered = new ArrayList<Recipient>();
    MimeMessage mimemsg = message.getMimeMessage();
    boolean deleteMessage = true;
    for (String targetServer : targets.keySet()) {
        Collection<Recipient> temp = targets.get(targetServer);
        if (!deliver(targetServer, temp, message, mimemsg)) {
            // Retry this message later
            deleteMessage = false;
            if (!temp.isEmpty()) {
                undelivered.addAll(temp);
            }
        }
    }
    if (!deleteMessage) {
        try {
            message.setRetryCount(message.getRetryCount() + 1);
            message.setLastUpdate(new Date());
            recipients.clear();
            recipients.addAll(undelivered);
            message.store();
        } catch (IOException e) {
        }
    }
}

From source file:fr.landel.utils.assertor.predicate.PredicateAssertorIterableTest.java

/**
 * Test method for {@link AssertorIterable#contains}.
 * /*from w  w  w  .  j  a v  a 2s.co m*/
 * @throws IOException
 *             On not contain
 */
@Test
public void testContains() throws IOException {
    final String el1 = "element1";
    final String el2 = "element2";

    final Set<String> set = new HashSet<>();
    set.add(el1);

    Assertor.<Set<String>, String>ofIterable().contains(el1).that(set)
            .orElseThrow("iterable doesn't contain the element %s*");
    Assertor.<Set<String>, String>ofIterable(EnumAnalysisMode.STREAM).contains(el1).that(set)
            .orElseThrow("iterable doesn't contain the element %s*");
    Assertor.<Set<String>, String>ofIterable(EnumAnalysisMode.PARALLEL).contains(el1).that(set)
            .orElseThrow("iterable doesn't contain the element %s*");

    assertException(() -> {
        Assertor.<Set<String>, String>ofIterable().contains(el2).that(set)
                .orElseThrow("iterable doesn't contain the element %2$s*");
        fail(ERROR);
    }, IllegalArgumentException.class, "iterable doesn't contain the element " + el2);

    assertException(() -> {
        Assertor.<Set<String>, String>ofIterable().contains(el2).that(set).orElseThrow(new IOException(), true);
        fail(ERROR);
    }, IOException.class);

    assertException(() -> {
        Assertor.<Set<String>, String>ofIterable().contains((String) null).that(set).orElseThrow();
        fail(ERROR);
    }, IllegalArgumentException.class, "the iterable '[element1]' should contain the object 'null'");

    set.clear();

    assertException(() -> {
        Assertor.<Set<String>, String>ofIterable().contains(el1).that(set).orElseThrow();
        fail(ERROR);
    }, IllegalArgumentException.class);

    assertException(() -> {
        Assertor.<Set<String>, String>ofIterable().contains(el1).that(set).orElseThrow();
        fail(ERROR);
    }, IllegalArgumentException.class, "the iterable cannot be null or empty");

    assertException(() -> {
        Assertor.<Iterable<String>, String>ofIterable().contains(el1).that((Iterable<String>) null)
                .orElseThrow();
        fail(ERROR);
    }, IllegalArgumentException.class, "the iterable cannot be null or empty");

    assertException(() -> {
        Assertor.<Set<String>, String>ofIterable().contains((String) null).that(set).orElseThrow();
        fail(ERROR);
    }, IllegalArgumentException.class, "the iterable cannot be null or empty");
}

From source file:org.apache.asterix.optimizer.rules.PushAggregateIntoNestedSubplanRule.java

private boolean collectVarsBottomUp(Mutable<ILogicalOperator> opRef, IOptimizationContext context,
        Map<LogicalVariable, Integer> nspListifyVarsCount,
        Map<LogicalVariable, AbstractOperatorWithNestedPlans> nspWithAgg,
        Map<LogicalVariable, Integer> nspAggVarToPlanIndex,
        Map<ILogicalExpression, ILogicalExpression> aggregateExprToVarExpr) throws AlgebricksException {
    AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue();
    context.addToDontApplySet(this, op1);
    boolean change = false;
    for (Mutable<ILogicalOperator> child : op1.getInputs()) {
        if (collectVarsBottomUp(child, context, nspListifyVarsCount, nspWithAgg, nspAggVarToPlanIndex,
                aggregateExprToVarExpr)) {
            change = true;/*from  w  ww .j a  v  a 2s .  c  om*/
        }
    }
    Set<LogicalVariable> used = new HashSet<>();
    VariableUtilities.getUsedVariables(op1, used);
    switch (op1.getOperatorTag()) {
    case ASSIGN:
    case SELECT:
        boolean found = false;
        // Do some prefiltering: check if the Assign uses any nsp vars.
        for (LogicalVariable v : used) {
            if (nspListifyVarsCount.get(v) != null) {
                found = true;
                break;
            }
        }
        if (!found) {
            break;
        }
        if (op1.getOperatorTag() == LogicalOperatorTag.ASSIGN) {
            AssignOperator assign = (AssignOperator) op1;
            for (Mutable<ILogicalExpression> exprRef : assign.getExpressions()) {
                Pair<Boolean, ILogicalExpression> p = extractAggFunctionsFromExpression(exprRef, nspWithAgg,
                        aggregateExprToVarExpr, context);
                if (p.first) {
                    change = true;
                    exprRef.setValue(p.second);
                }
            }
        }
        if (op1.getOperatorTag() == LogicalOperatorTag.SELECT) {
            SelectOperator select = (SelectOperator) op1;
            Mutable<ILogicalExpression> exprRef = select.getCondition();
            Pair<Boolean, ILogicalExpression> p = extractAggFunctionsFromExpression(exprRef, nspWithAgg,
                    aggregateExprToVarExpr, context);
            if (p.first) {
                change = true;
                exprRef.setValue(p.second);
            }
        }
        used.clear();
        VariableUtilities.getUsedVariables(op1, used);
        // increment the count for the ones which are still used
        for (LogicalVariable v : used) {
            Integer m = nspListifyVarsCount.get(v);
            if (m != null) {
                nspListifyVarsCount.put(v, m + 1);
            }
        }
        break;
    case SUBPLAN:
        // Try to push the subplan into a group-by operator if possible.
        for (LogicalVariable v : used) {
            Integer m = nspListifyVarsCount.get(v);
            if (m != null) {
                AbstractOperatorWithNestedPlans nspOp = nspWithAgg.get(v);
                if (pushSubplanAsAggIntoNestedSubplan(opRef, nspOp, v, nspListifyVarsCount, nspWithAgg,
                        nspAggVarToPlanIndex, context)) {
                    change = true;
                } else {
                    nspListifyVarsCount.put(v, m + 1);
                }
            }
        }
        if (!change) {
            // Collect aggregate variables for pushing aggregates into the subplan (if possible).
            collectAggregateVars(nspListifyVarsCount, nspWithAgg, nspAggVarToPlanIndex,
                    (AbstractOperatorWithNestedPlans) op1);
        }
        break;
    case GROUP:
        // Collect aggregate variables for pushing aggregates into the nested subplan
        // of the group by operator (if possible).
        collectAggregateVars(nspListifyVarsCount, nspWithAgg, nspAggVarToPlanIndex,
                (AbstractOperatorWithNestedPlans) op1);
        break;
    default:
        for (LogicalVariable v : used) {
            Integer m = nspListifyVarsCount.get(v);
            if (m != null) {
                nspListifyVarsCount.put(v, m + 1);
            }
        }
    }
    return change;
}

From source file:org.apache.syncope.client.enduser.resources.UserSelfCreateResource.java

@Override
protected ResourceResponse newResourceResponse(final Attributes attributes) {
    ResourceResponse response = new ResourceResponse();
    response.setContentType(MediaType.TEXT_PLAIN);
    try {/*w w w .j  a v a 2  s .c o  m*/
        HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest();

        if (!xsrfCheck(request)) {
            LOG.error("XSRF TOKEN is not matching");
            response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN is not matching");
            return response;
        }

        String jsonString = request.getReader().readLine();
        final UserTO userTO = MAPPER.readValue(jsonString, UserTO.class);

        if (!captchaCheck(request.getHeader("captcha"),
                request.getSession().getAttribute(SyncopeEnduserConstants.CAPTCHA_SESSION_KEY))) {

            throw new IllegalArgumentException("Entered captcha is not matching");
        }

        if (isSelfRegistrationAllowed() && userTO != null) {
            LOG.debug("User self registration request for [{}]", userTO.getUsername());
            LOG.trace("Request is [{}]", userTO);

            // check if request is compliant with customization form rules
            if (UserRequestValidator.compliant(userTO, SyncopeEnduserApplication.get().getCustomForm(), true)) {

                // 1. membership attributes management
                Set<AttrTO> membAttrs = new HashSet<>();
                userTO.getPlainAttrs().stream().filter(
                        attr -> (attr.getSchema().contains(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR)))
                        .forEachOrdered(attr -> {
                            String[] simpleAttrs = attr.getSchema()
                                    .split(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR);
                            MembershipTO membership = userTO.getMemberships().stream()
                                    .filter(memb -> simpleAttrs[0].equals(memb.getGroupName())).findFirst()
                                    .orElse(null);
                            if (membership == null) {
                                membership = new MembershipTO.Builder().group(null, simpleAttrs[0]).build();
                                userTO.getMemberships().add(membership);
                            }

                            AttrTO clone = SerializationUtils.clone(attr);
                            clone.setSchema(simpleAttrs[1]);
                            membership.getPlainAttrs().add(clone);
                            membAttrs.add(attr);
                        });
                userTO.getPlainAttrs().removeAll(membAttrs);

                // 2. millis -> Date conversion for PLAIN attributes of USER and its MEMBERSHIPS
                SyncopeEnduserSession.get().getDatePlainSchemas().stream().map(plainSchema -> {
                    millisToDate(userTO.getPlainAttrs(), plainSchema);
                    return plainSchema;
                }).forEachOrdered(plainSchema -> {
                    userTO.getMemberships().forEach(membership -> {
                        millisToDate(membership.getPlainAttrs(), plainSchema);
                    });
                });

                membAttrs.clear();
                userTO.getDerAttrs().stream().filter(
                        attr -> (attr.getSchema().contains(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR)))
                        .forEachOrdered(attr -> {
                            String[] simpleAttrs = attr.getSchema()
                                    .split(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR);
                            MembershipTO membership = userTO.getMemberships().stream()
                                    .filter(memb -> simpleAttrs[0].equals(memb.getGroupName())).findFirst()
                                    .orElse(null);
                            if (membership == null) {
                                membership = new MembershipTO.Builder().group(null, simpleAttrs[0]).build();
                                userTO.getMemberships().add(membership);
                            }

                            AttrTO clone = SerializationUtils.clone(attr);
                            clone.setSchema(simpleAttrs[1]);
                            membership.getDerAttrs().add(clone);
                            membAttrs.add(attr);
                        });
                userTO.getDerAttrs().removeAll(membAttrs);

                membAttrs.clear();
                userTO.getVirAttrs().stream().filter(
                        attr -> (attr.getSchema().contains(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR)))
                        .forEachOrdered(attr -> {
                            String[] simpleAttrs = attr.getSchema()
                                    .split(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR);
                            MembershipTO membership = userTO.getMemberships().stream()
                                    .filter(memb -> simpleAttrs[0].equals(memb.getGroupName())).findFirst()
                                    .orElse(null);
                            if (membership == null) {
                                membership = new MembershipTO.Builder().group(null, simpleAttrs[0]).build();
                                userTO.getMemberships().add(membership);
                            }

                            AttrTO clone = SerializationUtils.clone(attr);
                            clone.setSchema(simpleAttrs[1]);
                            membership.getVirAttrs().add(clone);
                            membAttrs.add(attr);
                        });
                userTO.getVirAttrs().removeAll(membAttrs);

                LOG.debug("Received user self registration request for user: [{}]", userTO.getUsername());
                LOG.trace("Received user self registration request is: [{}]", userTO);

                // adapt request and create user
                final Response res = SyncopeEnduserSession.get().getService(UserSelfService.class)
                        .create(userTO, true);

                buildResponse(response, res.getStatus(),
                        Response.Status.Family.SUCCESSFUL.equals(res.getStatusInfo().getFamily())
                                ? "User[ " + userTO.getUsername() + "] successfully created"
                                : "ErrorMessage{{ " + res.getStatusInfo().getReasonPhrase() + " }}");
            } else {
                LOG.warn("Incoming create request [{}] is not compliant with form customization rules. "
                        + "Create NOT allowed", userTO.getUsername());
                buildResponse(response, Response.Status.OK.getStatusCode(),
                        "User: " + userTO.getUsername() + " successfully created");
            }
        } else {
            response.setError(Response.Status.FORBIDDEN.getStatusCode(),
                    new StringBuilder().append("ErrorMessage{{")
                            .append(userTO == null ? "Request received is not valid }}"
                                    : "Self registration not allowed }}")
                            .toString());
        }
    } catch (Exception e) {
        LOG.error("Unable to create userTO", e);
        response.setError(Response.Status.BAD_REQUEST.getStatusCode(),
                new StringBuilder().append("ErrorMessage{{ ").append(e.getMessage()).append(" }}").toString());
    }
    return response;
}

From source file:com.enonic.cms.core.content.ContentStorer.java

/**
 * removes related content referencing this content from tRelatedContent and
 * marks as deleted in XML ContentData./*from  w ww.  j  a  va2  s .co  m*/
 *
 * @param content content to process
 */
private void doMarkReferencesToContentAsDeleted(final ContentEntity content) {
    final Set<ContentVersionEntity> relatedParentContentVersions = content.getRelatedParentContentVersions();

    for (final ContentVersionEntity contentVersionEntity : relatedParentContentVersions) {
        final ContentData contentData = contentVersionEntity.getContentData();
        final boolean removed = contentData.markReferencesToContentAsDeleted(content.getKey());
        if (removed) {
            // rebuild XML
            contentVersionEntity.setXmlDataFromContentData();
        }
    }

    // clean both sides of bi-directional relation. ( clean cached entities )
    for (final ContentVersionEntity contentVersionEntity : relatedParentContentVersions) {
        contentVersionEntity.removeRelatedChild(content);
    }
    relatedParentContentVersions.clear();
}

From source file:io.hops.metadata.util.RMUtilities.java

/**
 * Retrieves and sets RMNode containersToClean and FinishedApplications.
 *
 * @param rmnodeId//from ww w  .ja  va2 s.c o  m
 * @param containersToClean
 * @param finishedApplications
 * @throws IOException
 */
public static void setContainersToCleanAndFinishedApplications(final String rmnodeId,
        final Set<org.apache.hadoop.yarn.api.records.ContainerId> containersToClean,
        final List<ApplicationId> finishedApplications) throws IOException {
    LightWeightRequestHandler setContainersToCleanAndFinishedAppsHandler = new LightWeightRequestHandler(
            YARNOperationType.TEST) {
        @Override
        public Object performTask() throws StorageException {
            connector.beginTransaction();
            connector.readLock();
            //1. Retrieve ContainerIdToClean
            ContainerIdToCleanDataAccess tocleanDA = (ContainerIdToCleanDataAccess) YarnAPIStorageFactory
                    .getDataAccess(ContainerIdToCleanDataAccess.class);
            List<ContainerId> hopContainersToClean = tocleanDA.findByRMNode(rmnodeId);
            if (hopContainersToClean != null && !hopContainersToClean.isEmpty()) {
                Set<org.apache.hadoop.yarn.api.records.ContainerId> containersToCleanNDB = new TreeSet<org.apache.hadoop.yarn.api.records.ContainerId>();
                for (ContainerId hop : hopContainersToClean) {
                    containersToCleanNDB.add(ConverterUtils.toContainerId(hop.getContainerId()));
                }
                containersToClean.clear();
                containersToClean.addAll(containersToCleanNDB);
            }

            //2. Retrieve finishedApplications
            FinishedApplicationsDataAccess finishedAppsDA = (FinishedApplicationsDataAccess) YarnAPIStorageFactory
                    .getDataAccess(FinishedApplicationsDataAccess.class);
            List<FinishedApplications> hopFinishedApps = finishedAppsDA.findByRMNode(rmnodeId);
            if (hopFinishedApps != null && !hopFinishedApps.isEmpty()) {
                List<ApplicationId> finishedApplicationsNDB = new ArrayList<ApplicationId>();
                for (FinishedApplications hopFinishedApp : hopFinishedApps) {
                    finishedApplicationsNDB
                            .add(ConverterUtils.toApplicationId(hopFinishedApp.getApplicationId()));
                }
                finishedApplications.clear();
                finishedApplications.addAll(finishedApplicationsNDB);
            }

            connector.commit();
            return null;
        }
    };
    setContainersToCleanAndFinishedAppsHandler.handle();
}

From source file:com.netflix.genie.core.jpa.services.JpaCommandServiceImplIntegrationTests.java

/**
 * Test the get commands method.//from  w w w  . j a v a 2 s.com
 */
@Test
public void testGetCommandsByTags() {
    final Set<String> tags = Sets.newHashSet("prod");
    Page<Command> commands = this.service.getCommands(null, null, null, tags, PAGE);
    Assert.assertEquals(3, commands.getNumberOfElements());
    Assert.assertEquals(COMMAND_2_ID,
            commands.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new));
    Assert.assertEquals(COMMAND_3_ID,
            commands.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new));
    Assert.assertEquals(COMMAND_1_ID,
            commands.getContent().get(2).getId().orElseThrow(IllegalArgumentException::new));

    tags.add("pig");
    commands = this.service.getCommands(null, null, null, tags, PAGE);
    Assert.assertEquals(2, commands.getNumberOfElements());
    Assert.assertEquals(COMMAND_3_ID,
            commands.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new));
    Assert.assertEquals(COMMAND_1_ID,
            commands.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new));

    tags.clear();
    tags.add("hive");
    commands = this.service.getCommands(null, null, null, tags, PAGE);
    Assert.assertEquals(1, commands.getNumberOfElements());
    Assert.assertEquals(COMMAND_2_ID,
            commands.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new));

    tags.add("somethingThatWouldNeverReallyExist");
    commands = this.service.getCommands(null, null, null, tags, PAGE);
    Assert.assertTrue(commands.getContent().isEmpty());

    tags.clear();
    commands = this.service.getCommands(null, null, null, tags, PAGE);
    Assert.assertEquals(3, commands.getNumberOfElements());
    Assert.assertEquals(COMMAND_2_ID,
            commands.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new));
    Assert.assertEquals(COMMAND_3_ID,
            commands.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new));
    Assert.assertEquals(COMMAND_1_ID,
            commands.getContent().get(2).getId().orElseThrow(IllegalArgumentException::new));
}

From source file:org.apache.solr.handler.TestSolrConfigHandlerConcurrent.java

private void invokeBulkCall(String cacheName, List<String> errs, Map val) throws Exception {

    String payload = "{" + "'set-property' : {'query.CACHENAME.size':'CACHEVAL1',"
            + "                  'query.CACHENAME.initialSize':'CACHEVAL2'},"
            + "'set-property': {'query.CACHENAME.autowarmCount' : 'CACHEVAL3'}" + "}";

    Set<String> errmessages = new HashSet<>();
    for (int i = 1; i < 2; i++) {//make it  ahigher number
        RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
        String response;/*from ww w  .j a  v a2 s.  com*/
        String val1;
        String val2;
        String val3;
        try {
            payload = payload.replaceAll("CACHENAME", cacheName);
            val1 = String.valueOf(10 * i + 1);
            payload = payload.replace("CACHEVAL1", val1);
            val2 = String.valueOf(10 * i + 2);
            payload = payload.replace("CACHEVAL2", val2);
            val3 = String.valueOf(10 * i + 3);
            payload = payload.replace("CACHEVAL3", val3);

            response = publisher.post("/config?wt=json", SolrTestCaseJ4.json(payload));
        } finally {
            publisher.close();
        }

        Map map = (Map) getVal(new JSONParser(new StringReader(response)));
        Object errors = map.get("errors");
        if (errors != null) {
            errs.add(new String(Utils.toJSON(errors), StandardCharsets.UTF_8));
            return;
        }

        DocCollection coll = cloudClient.getZkStateReader().getClusterState().getCollection("collection1");
        List<String> urls = new ArrayList<>();
        for (Slice slice : coll.getSlices()) {
            for (Replica replica : slice.getReplicas())
                urls.add("" + replica.get(ZkStateReader.BASE_URL_PROP) + "/"
                        + replica.get(ZkStateReader.CORE_NAME_PROP));
        }

        //get another node
        String url = urls.get(urls.size());

        long startTime = System.nanoTime();
        long maxTimeoutSeconds = 20;
        while (TimeUnit.SECONDS.convert(System.nanoTime() - startTime,
                TimeUnit.NANOSECONDS) < maxTimeoutSeconds) {
            Thread.sleep(100);
            errmessages.clear();
            Map respMap = getAsMap(url + "/config/overlay?wt=json", cloudClient);
            Map m = (Map) respMap.get("overlay");
            if (m != null)
                m = (Map) m.get("props");
            if (m == null) {
                errmessages.add(StrUtils.formatString(
                        "overlay does not exist for cache: {0} , iteration: {1} response {2} ", cacheName, i,
                        respMap.toString()));
                continue;
            }

            Object o = getObjectByPath(m, true, asList("query", cacheName, "size"));
            if (!val1.equals(o))
                errmessages.add(
                        StrUtils.formatString("'size' property not set, expected = {0}, actual {1}", val1, o));

            o = getObjectByPath(m, true, asList("query", cacheName, "initialSize"));
            if (!val2.equals(o))
                errmessages.add(StrUtils
                        .formatString("'initialSize' property not set, expected = {0}, actual {1}", val2, o));

            o = getObjectByPath(m, true, asList("query", cacheName, "autowarmCount"));
            if (!val3.equals(o))
                errmessages.add(StrUtils
                        .formatString("'autowarmCount' property not set, expected = {0}, actual {1}", val3, o));
            if (errmessages.isEmpty())
                break;
        }
        if (!errmessages.isEmpty()) {
            errs.addAll(errmessages);
            return;
        }
    }

}