Example usage for java.util Map toString

List of usage examples for java.util Map toString

Introduction

In this page you can find the example usage for java.util Map toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.apache.solr.metrics.reporters.solr.SolrCloudReportersTest.java

@Test
public void testDefaultPlugins() throws Exception {
    String solrXml = IOUtils.toString(SolrCloudReportersTest.class.getResourceAsStream("/solr/solr.xml"),
            "UTF-8");
    configureCluster(2).withSolrXml(solrXml).configure();
    cluster.uploadConfigSet(Paths.get(TEST_PATH().toString(), "configsets", "minimal", "conf"), "test");
    System.out.println("ZK: " + cluster.getZkServer().getZkAddress());
    CollectionAdminRequest.createCollection("test_collection", "test", 2, 2).setMaxShardsPerNode(4)
            .process(cluster.getSolrClient());
    waitForState("Expected test_collection with 2 shards and 2 replicas", "test_collection",
            clusterShape(2, 2));//from  w  w  w  .  j av a 2s  .c  o m
    cluster.getJettySolrRunners().forEach(jetty -> {
        CoreContainer cc = jetty.getCoreContainer();
        SolrMetricManager metricManager = cc.getMetricManager();
        Map<String, SolrMetricReporter> reporters = metricManager.getReporters("solr.cluster");
        assertEquals(reporters.toString(), 0, reporters.size());
        for (String registryName : metricManager.registryNames(".*\\.shard[0-9]\\.replica.*")) {
            reporters = metricManager.getReporters(registryName);
            assertEquals(reporters.toString(), 0 + jmxReporter, reporters.size());
        }
    });
}

From source file:org.latticesoft.util.common.StringUtil.java

/** Formats a map */
public static String formatMap(Map map) {
    if (map != null) {
        return map.toString();
    }//from w  w  w . ja v a2s .  co  m
    return null;
}

From source file:org.apache.solr.metrics.JvmMetricsTest.java

@Test
public void testSetupJvmMetrics() throws Exception {
    SolrMetricManager metricManager = jetty.getCoreContainer().getMetricManager();
    Map<String, Metric> metrics = metricManager.registry("solr.jvm").getMetrics();
    assertTrue(metrics.size() > 0);// w  w w .ja v  a 2 s .  co  m
    assertTrue(metrics.toString(),
            metrics.entrySet().stream().filter(e -> e.getKey().startsWith("buffers.")).count() > 0);
    assertTrue(metrics.toString(),
            metrics.entrySet().stream().filter(e -> e.getKey().startsWith("classes.")).count() > 0);
    assertTrue(metrics.toString(),
            metrics.entrySet().stream().filter(e -> e.getKey().startsWith("os.")).count() > 0);
    assertTrue(metrics.toString(),
            metrics.entrySet().stream().filter(e -> e.getKey().startsWith("gc.")).count() > 0);
    assertTrue(metrics.toString(),
            metrics.entrySet().stream().filter(e -> e.getKey().startsWith("memory.")).count() > 0);
    assertTrue(metrics.toString(),
            metrics.entrySet().stream().filter(e -> e.getKey().startsWith("threads.")).count() > 0);
    assertTrue(metrics.toString(),
            metrics.entrySet().stream().filter(e -> e.getKey().startsWith("system.")).count() > 0);
}

From source file:com.griddynamics.banshun.web.View.java

@Override
protected void renderMergedOutputModel(final Map<String, Object> model, final HttpServletRequest request,
        final HttpServletResponse response) throws Exception {
    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");
    response.getOutputStream().write(model.toString().getBytes());
    response.getOutputStream().close();/* w w w .  j  a  v  a2  s .  c  om*/
}

From source file:azkaban.project.FlowTrigger.java

/**
 * check uniqueness of dependency type and params
 *///w ww  .j av a  2s  .c o  m
private void validateDepDefinitionUniqueness(final List<FlowTriggerDependency> dependencies) {
    final Set<String> seen = new HashSet<>();
    for (final FlowTriggerDependency dep : dependencies) {
        final Map<String, String> props = dep.getProps();
        // set.add() returns false when there exists duplicate
        Preconditions.checkArgument(seen.add(dep.getType() + ":" + props.toString()), String.format(
                "duplicate dependency config %s found, dependency config should be unique", dep.getName()));
    }
}

From source file:coral.RessyncServable.java

/**
 * check if the file needs to be updated, if yes, send out a get request
 *///w w w .j a va  2 s  .c  om
@Override
public void process(Message cmd, BlockingQueue<Message> outQueue) {
    if (cmd == null) {
        //         queue = outQueue;
    } else {

        String filename = cmd.getContent();

        if (logger.isDebugEnabled()) {
            logger.debug("check  " + filename + " - " + cmd.getFullContent());
        }

        Map<String, String> q = CoralUtils.urlToMap(cmd.getFullContent());

        if (logger.isDebugEnabled()) {
            logger.debug("check map " + q.toString());
        }

        final File file = new File(res, filename);

        logger.debug("check file " + file.getAbsolutePath());

        boolean request = false;
        if (file.exists()) {
            long version = file.lastModified();

            long expectedVersion = Long.parseLong(q.get("version"));

            if (expectedVersion > version) {
                request = true;
            }
        } else {
            request = true;
        }

        if (request) {
            outQueue.add(new Message(q.get("synccmd"), new byte[] {}));
        }
    }
}

From source file:org.codelabor.system.file.web.struts.action.FileDownloadAction.java

@Override
protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    Map<String, Object> paramMap = RequestUtils.getParameterMap(request);
    logger.debug(paramMap.toString());
    String fileId = (String) paramMap.get("fileId");

    StreamInfo streamInfo = null;//from  w w w. j a v  a2 s  . c o m
    WebApplicationContext ctx = WebApplicationContextUtils
            .getRequiredWebApplicationContext(servlet.getServletContext());
    FileManager fileManager = (FileManager) ctx.getBean("fileManager");

    FileDTO fileDTO = fileManager.selectFileByFileId(fileId);
    logger.debug("fileDTO: {}", fileDTO);

    String repositoryPath = fileDTO.getRepositoryPath();
    String uniqueFilename = fileDTO.getUniqueFilename();
    String realFilename = fileDTO.getRealFilename();

    StringBuilder sb = new StringBuilder();

    // FILE_SYSTEM
    if (StringUtils.isNotEmpty(repositoryPath)) {
        sb.append(repositoryPath);
        if (!repositoryPath.endsWith(File.separator)) {
            sb.append(File.separator);
        }
        sb.append(uniqueFilename);
        File file = new File(sb.toString());
        streamInfo = new FileStreamInfo(org.codelabor.system.file.FileConstants.CONTENT_TYPE, file);
        // DATABASE
    } else {
        byte[] bytes = fileDTO.getBytes();
        streamInfo = new ByteArrayStreamInfo(org.codelabor.system.file.FileConstants.CONTENT_TYPE, bytes);
    }
    // set response contenttype, header
    String encodedRealFilename = URLEncoder.encode(realFilename, "UTF-8");
    logger.debug("realFilename: {}", realFilename);
    logger.debug("encodedRealFilename: {}", encodedRealFilename);

    response.setContentType(org.codelabor.system.file.FileConstants.CONTENT_TYPE);
    sb.setLength(0);
    if (request.getHeader(HttpRequestHeaderConstants.USER_AGENT).indexOf("MSIE5.5") > -1) {
        sb.append("filename=");
    } else {
        sb.append("attachment; filename=");
    }
    // stringBuilder.append("\"");
    sb.append(encodedRealFilename);
    // stringBuilder.append("\"");
    response.setHeader(HttpResponseHeaderConstants.CONTENT_DISPOSITION, sb.toString());

    logger.debug("header: {}", sb.toString());
    logger.debug("character encoding: {}", response.getCharacterEncoding());
    logger.debug("content type: {}", response.getContentType());
    logger.debug("bufferSize: {}", response.getBufferSize());
    logger.debug("locale: {}", response.getLocale());
    return streamInfo;
}

From source file:com.oakhole.voa.web.WeixinController.java

/**
 * ??//from   w  w  w.  j  ava 2 s  .com
 *
 * @return
 */
@RequestMapping(method = RequestMethod.POST)
public String process(ServletRequest request) {
    Map<String, String> map = null;
    try {
        map = XMLMapper.parseXml(request.getInputStream());
    } catch (Exception e) {
        e.printStackTrace();
    }
    logger.info("map:{}", map.toString());
    if (!map.isEmpty()) {
        if (MessageType.EVENT_MESSAGE.equals(map.get(MessageType.MESSAGE_TYPE))) {
            return this.eventService.processEvent(map);
        }
        return this.messageService.processCommander(map);
    }
    return "";
}

From source file:com.bendb.thrifty.testing.ThriftTestHandler.java

@Override
public Map<Integer, Integer> testMap(Map<Integer, Integer> thing) throws TException {
    out.printf("testMap(\"%s\")\n", thing.toString());
    return thing;
}

From source file:com.trenako.results.SearchRangeTests.java

@Test
public void shouldReturnParamsAsMapsOnlyForNotNullValues() {
    SearchRange range = new SearchRange(20, new Sort(Direction.DESC, "name"), null, null);

    Map<String, Object> params = range.asMap();

    String expected = "{dir=DESC, size=20, sort=name}";

    assertNotNull(params);/*  w  w w . j  a va  2 s .co m*/
    assertEquals(3, params.size());
    assertEquals(expected, params.toString());
}