code: public boolean replaceNode(final Node oldOne, final @Nonnull Node newOne) throws IOException {
          if (oldOne == nodes.get(oldOne.getNodeName())) {
              // use the queue lock until Nodes has a way of directly modifying a single node.
              Queue.withLock(new Runnable() {
                  public void run() {
                      Nodes.this.nodes.remove(oldOne.getNodeName());
                      Nodes.this.nodes.put(newOne.getNodeName(), newOne);
                      jenkins.updateComputerList();
                      jenkins.trimLabels();
                  }
              });
              updateNode(newOne);
              if (!newOne.getNodeName().equals(oldOne.getNodeName())) {
                  Util.deleteRecursive(new File(getNodesDir(), oldOne.getNodeName()));
              }
              NodeListener.fireOnUpdated(oldOne, newOne);
  
              return true;
          } else {
              return false;
          }
      }
docs: Replace node of given name.
  
  @return {@code true} if node was replaced.
  @since 2.8