コード例 #1
0
ファイル: SolrConfig.java プロジェクト: hunglsx/lucene-solr
  public static ConfigOverlay getConfigOverlay(SolrResourceLoader loader) {
    InputStream in = null;
    InputStreamReader isr = null;
    try {
      try {
        in = loader.openResource(ConfigOverlay.RESOURCE_NAME);
      } catch (IOException e) {
        // TODO: we should be explicitly looking for file not found exceptions
        // and logging if it's not the expected IOException
        // hopefully no problem, assume no overlay.json file
        return new ConfigOverlay(Collections.EMPTY_MAP, -1);
      }

      int version = 0; // will be always 0 for file based resourceLoader
      if (in instanceof ZkSolrResourceLoader.ZkByteArrayInputStream) {
        version = ((ZkSolrResourceLoader.ZkByteArrayInputStream) in).getStat().getVersion();
        log.info("config overlay loaded . version : {} ", version);
      }
      isr = new InputStreamReader(in, StandardCharsets.UTF_8);
      Map m = (Map) ObjectBuilder.getVal(new JSONParser(isr));
      return new ConfigOverlay(m, version);
    } catch (Exception e) {
      throw new SolrException(ErrorCode.SERVER_ERROR, "Error reading config overlay", e);
    } finally {
      IOUtils.closeQuietly(isr);
      IOUtils.closeQuietly(in);
    }
  }
コード例 #2
0
 public static void runConfigCommand(RestTestHarness harness, String uri, String payload)
     throws IOException {
   String json = SolrTestCaseJ4.json(payload);
   log.info("going to send config command. path {} , payload: {}", uri, payload);
   String response = harness.post(uri, json);
   Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
   assertNull(response, map.get("errors"));
 }
コード例 #3
0
 public static Map getRespMap(String path, RestTestHarness restHarness) throws Exception {
   String response = restHarness.query(path);
   try {
     return (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
   } catch (JSONParser.ParseException e) {
     log.error(response);
     return Collections.emptyMap();
   }
 }
コード例 #4
0
 @Override
 protected Object parseText(Reader reader, String resourceId) throws IOException {
   return ObjectBuilder.getVal(new JSONParser(reader));
 }