コード例 #1
0
    private ConfigOverlay applyRequestHandler(CommandOperation op, ConfigOverlay overlay) {
      String name = op.getStr(NAME);
      op.getStr(CLASS_NAME);
      op.getMap(PluginInfo.DEFAULTS, null);
      op.getMap(PluginInfo.INVARIANTS, null);
      op.getMap(PluginInfo.APPENDS, null);
      if (op.hasError()) return overlay;

      if (CREATE_REQHANDLER.equals(op.name)) {
        if (overlay.getReqHandlers().containsKey(name)) {
          op.addError(
              MessageFormat.format(
                  " ''{0}'' already exists . Do an ''{1}'' , if you want to change it ",
                  name, UPDATE_REQHANDLER));
          return overlay;
        } else {
          return overlay.addReqHandler(op.getDataMap());
        }
      } else if (UPDATE_REQHANDLER.equals(op.name)) {
        if (!overlay.getReqHandlers().containsKey(name)) {
          op.addError(
              MessageFormat.format(
                  " ''{0}'' does not exist . Do an ''{1}'' , if you want to create it ",
                  name, CREATE_REQHANDLER));
          return overlay;
        } else {
          return overlay.addReqHandler(op.getDataMap());
        }
      }

      return overlay;
    }
コード例 #2
0
 private ConfigOverlay applyDeleteHandler(CommandOperation op, ConfigOverlay overlay) {
   String name = op.getStr(CommandOperation.ROOT_OBJ);
   if (op.hasError()) return overlay;
   if (overlay.getReqHandlers().containsKey(name)) {
     return overlay.deleteHandler(name);
   } else {
     op.addError(MessageFormat.format("NO such requestHandler ''{0}'' ", name));
     return overlay;
   }
 }
コード例 #3
0
 private ConfigOverlay applyUnsetUserProp(CommandOperation op, ConfigOverlay overlay) {
   List<String> name = op.getStrs(CommandOperation.ROOT_OBJ);
   if (op.hasError()) return overlay;
   for (String o : name) {
     if (!overlay.getUserProps().containsKey(o)) {
       op.addError(format("No such property ''{0}''", name));
     } else {
       overlay = overlay.unsetUserProperty(o);
     }
   }
   return overlay;
 }
コード例 #4
0
    private ConfigOverlay applyUnset(CommandOperation op, ConfigOverlay overlay) {
      List<String> name = op.getStrs(CommandOperation.ROOT_OBJ);
      if (op.hasError()) return overlay;

      for (String o : name) {
        if (!ConfigOverlay.isEditableProp(o, false, null)) {
          op.addError(format(NOT_EDITABLE, name));
        } else {
          overlay = overlay.unsetProperty(o);
        }
      }
      return overlay;
    }
コード例 #5
0
 private ConfigOverlay applySetProp(CommandOperation op, ConfigOverlay overlay) {
   Map<String, Object> m = op.getDataMap();
   if (op.hasError()) return overlay;
   for (Map.Entry<String, Object> e : m.entrySet()) {
     String name = e.getKey();
     Object val = e.getValue();
     if (!ConfigOverlay.isEditableProp(name, false, null)) {
       op.addError(format(NOT_EDITABLE, name));
       continue;
     }
     overlay = overlay.setProperty(name, val);
   }
   return overlay;
 }
コード例 #6
0
    private void handleCommands(List<CommandOperation> ops, ConfigOverlay overlay)
        throws IOException {
      for (CommandOperation op : ops) {
        switch (op.name) {
          case SET_PROPERTY:
            overlay = applySetProp(op, overlay);
            break;
          case UNSET_PROPERTY:
            overlay = applyUnset(op, overlay);
            break;
          case SET_USER_PROPERTY:
            overlay = applySetUserProp(op, overlay);
            break;
          case UNSET_USER_PROPERTY:
            overlay = applyUnsetUserProp(op, overlay);
            break;
          case UPDATE_REQHANDLER:
          case CREATE_REQHANDLER:
            overlay = applyRequestHandler(op, overlay);
            break;
          case DELETE_REQHANDLER:
            overlay = applyDeleteHandler(op, overlay);
            break;
        }
      }
      List errs = CommandOperation.captureErrors(ops);
      if (!errs.isEmpty()) {
        resp.add(CommandOperation.ERR_MSGS, errs);
        return;
      }

      SolrResourceLoader loader = req.getCore().getResourceLoader();
      if (loader instanceof ZkSolrResourceLoader) {
        ZkController.persistConfigResourceToZooKeeper(
            loader,
            overlay.getZnodeVersion(),
            ConfigOverlay.RESOURCE_NAME,
            overlay.toByteArray(),
            true);

      } else {
        SolrResourceLoader.persistConfLocally(
            loader, ConfigOverlay.RESOURCE_NAME, overlay.toByteArray());
        req.getCore().getCoreDescriptor().getCoreContainer().reload(req.getCore().getName());
      }
    }
コード例 #7
0
 private ConfigOverlay applySetUserProp(CommandOperation op, ConfigOverlay overlay) {
   Map<String, Object> m = op.getDataMap();
   if (op.hasError()) return overlay;
   for (Map.Entry<String, Object> e : m.entrySet()) {
     String name = e.getKey();
     Object val = e.getValue();
     overlay = overlay.setUserProperty(name, val);
   }
   return overlay;
 }