Java 类org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange 实例源码

项目:aliyun-oss-hadoop-fs    文件:ReconfigurationProtocolUtils.java   
public static ReconfigurationTaskStatus getReconfigurationStatus(
    GetReconfigurationStatusResponseProto response) {
  Map<PropertyChange, Optional<String>> statusMap = null;
  long startTime;
  long endTime = 0;

  startTime = response.getStartTime();
  if (response.hasEndTime()) {
    endTime = response.getEndTime();
  }
  if (response.getChangesCount() > 0) {
    statusMap = Maps.newHashMap();
    for (GetReconfigurationStatusConfigChangeProto change : response
        .getChangesList()) {
      PropertyChange pc = new PropertyChange(change.getName(),
          change.getNewValue(), change.getOldValue());
      String errorMessage = null;
      if (change.hasErrorMessage()) {
        errorMessage = change.getErrorMessage();
      }
      statusMap.put(pc, Optional.fromNullable(errorMessage));
    }
  }
  return new ReconfigurationTaskStatus(startTime, endTime, statusMap);
}
项目:hadoop-oss    文件:ReconfigurableBase.java   
public void run() {
  LOG.info("Starting reconfiguration task.");
  final Configuration oldConf = parent.getConf();
  final Configuration newConf = parent.getNewConf();
  final Collection<PropertyChange> changes =
      parent.getChangedProperties(newConf, oldConf);
  Map<PropertyChange, Optional<String>> results = Maps.newHashMap();
  for (PropertyChange change : changes) {
    String errorMessage = null;
    if (!parent.isPropertyReconfigurable(change.prop)) {
      LOG.info(String.format(
          "Property %s is not configurable: old value: %s, new value: %s",
          change.prop, change.oldVal, change.newVal));
      continue;
    }
    LOG.info("Change property: " + change.prop + " from \""
        + ((change.oldVal == null) ? "<default>" : change.oldVal)
        + "\" to \"" + ((change.newVal == null) ? "<default>" : change.newVal)
        + "\".");
    try {
      String effectiveValue =
          parent.reconfigurePropertyImpl(change.prop, change.newVal);
      if (change.newVal != null) {
        oldConf.set(change.prop, effectiveValue);
      } else {
        oldConf.unset(change.prop);
      }
    } catch (ReconfigurationException e) {
      errorMessage = e.getCause().getMessage();
    }
    results.put(change, Optional.fromNullable(errorMessage));
  }

  synchronized (parent.reconfigLock) {
    parent.endTime = Time.now();
    parent.status = Collections.unmodifiableMap(results);
    parent.reconfigThread = null;
  }
}
项目:hadoop-oss    文件:TestReconfiguration.java   
/**
 * Test ReconfigurationUtil.getChangedProperties.
 */
@Test
public void testGetChangedProperties() {
  Collection<ReconfigurationUtil.PropertyChange> changes = 
    ReconfigurationUtil.getChangedProperties(conf2, conf1);

  assertTrue("expected 3 changed properties but got " + changes.size(),
             changes.size() == 3);

  boolean changeFound = false;
  boolean unsetFound = false;
  boolean setFound = false;

  for (ReconfigurationUtil.PropertyChange c: changes) {
    if (c.prop.equals(PROP2) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal != null && c.newVal.equals(VAL2)) {
      changeFound = true;
    } else if (c.prop.equals(PROP3) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal == null) {
      unsetFound = true;
    } else if (c.prop.equals(PROP4) && c.oldVal == null &&
        c.newVal != null && c.newVal.equals(VAL1)) {
      setFound = true;
    } 
  }

  assertTrue("not all changes have been applied",
             changeFound && unsetFound && setFound);
}
项目:hadoop    文件:ClientDatanodeProtocolTranslatorPB.java   
@Override
public ReconfigurationTaskStatus getReconfigurationStatus() throws IOException {
  GetReconfigurationStatusResponseProto response;
  Map<PropertyChange, Optional<String>> statusMap = null;
  long startTime;
  long endTime = 0;
  try {
    response = rpcProxy.getReconfigurationStatus(NULL_CONTROLLER,
        VOID_GET_RECONFIG_STATUS);
    startTime = response.getStartTime();
    if (response.hasEndTime()) {
      endTime = response.getEndTime();
    }
    if (response.getChangesCount() > 0) {
      statusMap = Maps.newHashMap();
      for (GetReconfigurationStatusConfigChangeProto change :
          response.getChangesList()) {
        PropertyChange pc = new PropertyChange(
            change.getName(), change.getNewValue(), change.getOldValue());
        String errorMessage = null;
        if (change.hasErrorMessage()) {
          errorMessage = change.getErrorMessage();
        }
        statusMap.put(pc, Optional.fromNullable(errorMessage));
      }
    }
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
  return new ReconfigurationTaskStatus(startTime, endTime, statusMap);
}
项目:hadoop    文件:ReconfigurableBase.java   
public void run() {
  LOG.info("Starting reconfiguration task.");
  Configuration oldConf = this.parent.getConf();
  Configuration newConf = new Configuration();
  Collection<PropertyChange> changes =
      this.parent.getChangedProperties(newConf, oldConf);
  Map<PropertyChange, Optional<String>> results = Maps.newHashMap();
  for (PropertyChange change : changes) {
    String errorMessage = null;
    if (!this.parent.isPropertyReconfigurable(change.prop)) {
      errorMessage = "Property " + change.prop +
          " is not reconfigurable";
      LOG.info(errorMessage);
      results.put(change, Optional.of(errorMessage));
      continue;
    }
    LOG.info("Change property: " + change.prop + " from \""
        + ((change.oldVal == null) ? "<default>" : change.oldVal)
        + "\" to \"" + ((change.newVal == null) ? "<default>" : change.newVal)
        + "\".");
    try {
      this.parent.reconfigurePropertyImpl(change.prop, change.newVal);
    } catch (ReconfigurationException e) {
      errorMessage = e.getCause().getMessage();
    }
    results.put(change, Optional.fromNullable(errorMessage));
  }

  synchronized (this.parent.reconfigLock) {
    this.parent.endTime = Time.now();
    this.parent.status = Collections.unmodifiableMap(results);
    this.parent.reconfigThread = null;
  }
}
项目:hadoop    文件:TestReconfiguration.java   
/**
 * Test ReconfigurationUtil.getChangedProperties.
 */
@Test
public void testGetChangedProperties() {
  Collection<ReconfigurationUtil.PropertyChange> changes = 
    ReconfigurationUtil.getChangedProperties(conf2, conf1);

  assertTrue("expected 3 changed properties but got " + changes.size(),
             changes.size() == 3);

  boolean changeFound = false;
  boolean unsetFound = false;
  boolean setFound = false;

  for (ReconfigurationUtil.PropertyChange c: changes) {
    if (c.prop.equals(PROP2) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal != null && c.newVal.equals(VAL2)) {
      changeFound = true;
    } else if (c.prop.equals(PROP3) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal == null) {
      unsetFound = true;
    } else if (c.prop.equals(PROP4) && c.oldVal == null &&
        c.newVal != null && c.newVal.equals(VAL1)) {
      setFound = true;
    } 
  }

  assertTrue("not all changes have been applied",
             changeFound && unsetFound && setFound);
}
项目:aliyun-oss-hadoop-fs    文件:ReconfigurableBase.java   
public void run() {
  LOG.info("Starting reconfiguration task.");
  Configuration oldConf = this.parent.getConf();
  Configuration newConf = this.parent.getNewConf();
  Collection<PropertyChange> changes =
      this.parent.getChangedProperties(newConf, oldConf);
  Map<PropertyChange, Optional<String>> results = Maps.newHashMap();
  for (PropertyChange change : changes) {
    String errorMessage = null;
    if (!this.parent.isPropertyReconfigurable(change.prop)) {
      LOG.info(String.format(
          "Property %s is not configurable: old value: %s, new value: %s",
          change.prop, change.oldVal, change.newVal));
      continue;
    }
    LOG.info("Change property: " + change.prop + " from \""
        + ((change.oldVal == null) ? "<default>" : change.oldVal)
        + "\" to \"" + ((change.newVal == null) ? "<default>" : change.newVal)
        + "\".");
    try {
      this.parent.reconfigurePropertyImpl(change.prop, change.newVal);
    } catch (ReconfigurationException e) {
      errorMessage = e.getCause().getMessage();
    }
    results.put(change, Optional.fromNullable(errorMessage));
  }

  synchronized (this.parent.reconfigLock) {
    this.parent.endTime = Time.now();
    this.parent.status = Collections.unmodifiableMap(results);
    this.parent.reconfigThread = null;
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestReconfiguration.java   
/**
 * Test ReconfigurationUtil.getChangedProperties.
 */
@Test
public void testGetChangedProperties() {
  Collection<ReconfigurationUtil.PropertyChange> changes = 
    ReconfigurationUtil.getChangedProperties(conf2, conf1);

  assertTrue("expected 3 changed properties but got " + changes.size(),
             changes.size() == 3);

  boolean changeFound = false;
  boolean unsetFound = false;
  boolean setFound = false;

  for (ReconfigurationUtil.PropertyChange c: changes) {
    if (c.prop.equals(PROP2) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal != null && c.newVal.equals(VAL2)) {
      changeFound = true;
    } else if (c.prop.equals(PROP3) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal == null) {
      unsetFound = true;
    } else if (c.prop.equals(PROP4) && c.oldVal == null &&
        c.newVal != null && c.newVal.equals(VAL1)) {
      setFound = true;
    } 
  }

  assertTrue("not all changes have been applied",
             changeFound && unsetFound && setFound);
}
项目:big-c    文件:ClientDatanodeProtocolTranslatorPB.java   
@Override
public ReconfigurationTaskStatus getReconfigurationStatus() throws IOException {
  GetReconfigurationStatusResponseProto response;
  Map<PropertyChange, Optional<String>> statusMap = null;
  long startTime;
  long endTime = 0;
  try {
    response = rpcProxy.getReconfigurationStatus(NULL_CONTROLLER,
        VOID_GET_RECONFIG_STATUS);
    startTime = response.getStartTime();
    if (response.hasEndTime()) {
      endTime = response.getEndTime();
    }
    if (response.getChangesCount() > 0) {
      statusMap = Maps.newHashMap();
      for (GetReconfigurationStatusConfigChangeProto change :
          response.getChangesList()) {
        PropertyChange pc = new PropertyChange(
            change.getName(), change.getNewValue(), change.getOldValue());
        String errorMessage = null;
        if (change.hasErrorMessage()) {
          errorMessage = change.getErrorMessage();
        }
        statusMap.put(pc, Optional.fromNullable(errorMessage));
      }
    }
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
  return new ReconfigurationTaskStatus(startTime, endTime, statusMap);
}
项目:big-c    文件:ReconfigurableBase.java   
public void run() {
  LOG.info("Starting reconfiguration task.");
  Configuration oldConf = this.parent.getConf();
  Configuration newConf = new Configuration();
  Collection<PropertyChange> changes =
      this.parent.getChangedProperties(newConf, oldConf);
  Map<PropertyChange, Optional<String>> results = Maps.newHashMap();
  for (PropertyChange change : changes) {
    String errorMessage = null;
    if (!this.parent.isPropertyReconfigurable(change.prop)) {
      errorMessage = "Property " + change.prop +
          " is not reconfigurable";
      LOG.info(errorMessage);
      results.put(change, Optional.of(errorMessage));
      continue;
    }
    LOG.info("Change property: " + change.prop + " from \""
        + ((change.oldVal == null) ? "<default>" : change.oldVal)
        + "\" to \"" + ((change.newVal == null) ? "<default>" : change.newVal)
        + "\".");
    try {
      this.parent.reconfigurePropertyImpl(change.prop, change.newVal);
    } catch (ReconfigurationException e) {
      errorMessage = e.getCause().getMessage();
    }
    results.put(change, Optional.fromNullable(errorMessage));
  }

  synchronized (this.parent.reconfigLock) {
    this.parent.endTime = Time.now();
    this.parent.status = Collections.unmodifiableMap(results);
    this.parent.reconfigThread = null;
  }
}
项目:big-c    文件:TestReconfiguration.java   
/**
 * Test ReconfigurationUtil.getChangedProperties.
 */
@Test
public void testGetChangedProperties() {
  Collection<ReconfigurationUtil.PropertyChange> changes = 
    ReconfigurationUtil.getChangedProperties(conf2, conf1);

  assertTrue("expected 3 changed properties but got " + changes.size(),
             changes.size() == 3);

  boolean changeFound = false;
  boolean unsetFound = false;
  boolean setFound = false;

  for (ReconfigurationUtil.PropertyChange c: changes) {
    if (c.prop.equals(PROP2) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal != null && c.newVal.equals(VAL2)) {
      changeFound = true;
    } else if (c.prop.equals(PROP3) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal == null) {
      unsetFound = true;
    } else if (c.prop.equals(PROP4) && c.oldVal == null &&
        c.newVal != null && c.newVal.equals(VAL1)) {
      setFound = true;
    } 
  }

  assertTrue("not all changes have been applied",
             changeFound && unsetFound && setFound);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ClientDatanodeProtocolTranslatorPB.java   
@Override
public ReconfigurationTaskStatus getReconfigurationStatus() throws IOException {
  GetReconfigurationStatusResponseProto response;
  Map<PropertyChange, Optional<String>> statusMap = null;
  long startTime;
  long endTime = 0;
  try {
    response = rpcProxy.getReconfigurationStatus(NULL_CONTROLLER,
        VOID_GET_RECONFIG_STATUS);
    startTime = response.getStartTime();
    if (response.hasEndTime()) {
      endTime = response.getEndTime();
    }
    if (response.getChangesCount() > 0) {
      statusMap = Maps.newHashMap();
      for (GetReconfigurationStatusConfigChangeProto change :
          response.getChangesList()) {
        PropertyChange pc = new PropertyChange(
            change.getName(), change.getNewValue(), change.getOldValue());
        String errorMessage = null;
        if (change.hasErrorMessage()) {
          errorMessage = change.getErrorMessage();
        }
        statusMap.put(pc, Optional.fromNullable(errorMessage));
      }
    }
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
  return new ReconfigurationTaskStatus(startTime, endTime, statusMap);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ReconfigurableBase.java   
public void run() {
  LOG.info("Starting reconfiguration task.");
  Configuration oldConf = this.parent.getConf();
  Configuration newConf = new Configuration();
  Collection<PropertyChange> changes =
      this.parent.getChangedProperties(newConf, oldConf);
  Map<PropertyChange, Optional<String>> results = Maps.newHashMap();
  for (PropertyChange change : changes) {
    String errorMessage = null;
    if (!this.parent.isPropertyReconfigurable(change.prop)) {
      errorMessage = "Property " + change.prop +
          " is not reconfigurable";
      LOG.info(errorMessage);
      results.put(change, Optional.of(errorMessage));
      continue;
    }
    LOG.info("Change property: " + change.prop + " from \""
        + ((change.oldVal == null) ? "<default>" : change.oldVal)
        + "\" to \"" + ((change.newVal == null) ? "<default>" : change.newVal)
        + "\".");
    try {
      this.parent.reconfigurePropertyImpl(change.prop, change.newVal);
    } catch (ReconfigurationException e) {
      errorMessage = e.getCause().getMessage();
    }
    results.put(change, Optional.fromNullable(errorMessage));
  }

  synchronized (this.parent.reconfigLock) {
    this.parent.endTime = Time.now();
    this.parent.status = Collections.unmodifiableMap(results);
    this.parent.reconfigThread = null;
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestReconfiguration.java   
/**
 * Test ReconfigurationUtil.getChangedProperties.
 */
@Test
public void testGetChangedProperties() {
  Collection<ReconfigurationUtil.PropertyChange> changes = 
    ReconfigurationUtil.getChangedProperties(conf2, conf1);

  assertTrue("expected 3 changed properties but got " + changes.size(),
             changes.size() == 3);

  boolean changeFound = false;
  boolean unsetFound = false;
  boolean setFound = false;

  for (ReconfigurationUtil.PropertyChange c: changes) {
    if (c.prop.equals(PROP2) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal != null && c.newVal.equals(VAL2)) {
      changeFound = true;
    } else if (c.prop.equals(PROP3) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal == null) {
      unsetFound = true;
    } else if (c.prop.equals(PROP4) && c.oldVal == null &&
        c.newVal != null && c.newVal.equals(VAL1)) {
      setFound = true;
    } 
  }

  assertTrue("not all changes have been applied",
             changeFound && unsetFound && setFound);
}
项目:FlexMap    文件:ClientDatanodeProtocolTranslatorPB.java   
@Override
public ReconfigurationTaskStatus getReconfigurationStatus() throws IOException {
  GetReconfigurationStatusResponseProto response;
  Map<PropertyChange, Optional<String>> statusMap = null;
  long startTime;
  long endTime = 0;
  try {
    response = rpcProxy.getReconfigurationStatus(NULL_CONTROLLER,
        VOID_GET_RECONFIG_STATUS);
    startTime = response.getStartTime();
    if (response.hasEndTime()) {
      endTime = response.getEndTime();
    }
    if (response.getChangesCount() > 0) {
      statusMap = Maps.newHashMap();
      for (GetReconfigurationStatusConfigChangeProto change :
          response.getChangesList()) {
        PropertyChange pc = new PropertyChange(
            change.getName(), change.getNewValue(), change.getOldValue());
        String errorMessage = null;
        if (change.hasErrorMessage()) {
          errorMessage = change.getErrorMessage();
        }
        statusMap.put(pc, Optional.fromNullable(errorMessage));
      }
    }
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
  return new ReconfigurationTaskStatus(startTime, endTime, statusMap);
}
项目:hops    文件:TestReconfiguration.java   
/**
 * Test ReconfigurationUtil.getChangedProperties.
 */
@Test
public void testGetChangedProperties() {
  Collection<ReconfigurationUtil.PropertyChange> changes = 
    ReconfigurationUtil.getChangedProperties(conf2, conf1);

  assertTrue("expected 3 changed properties but got " + changes.size(),
             changes.size() == 3);

  boolean changeFound = false;
  boolean unsetFound = false;
  boolean setFound = false;

  for (ReconfigurationUtil.PropertyChange c: changes) {
    if (c.prop.equals(PROP2) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal != null && c.newVal.equals(VAL2)) {
      changeFound = true;
    } else if (c.prop.equals(PROP3) && c.oldVal != null && c.oldVal.equals(VAL1) &&
        c.newVal == null) {
      unsetFound = true;
    } else if (c.prop.equals(PROP4) && c.oldVal == null &&
        c.newVal != null && c.newVal.equals(VAL1)) {
      setFound = true;
    } 
  }

  assertTrue("not all changes have been applied",
             changeFound && unsetFound && setFound);
}
项目:hadoop-oss    文件:ReconfigurationTaskStatus.java   
public ReconfigurationTaskStatus(long startTime, long endTime,
    Map<ReconfigurationUtil.PropertyChange, Optional<String>> status) {
  this.startTime = startTime;
  this.endTime = endTime;
  this.status = status;
}
项目:hadoop-oss    文件:ReconfigurationTaskStatus.java   
public final Map<PropertyChange, Optional<String>> getStatus() {
  return status;
}
项目:hadoop-oss    文件:ReconfigurableBase.java   
@VisibleForTesting
public Collection<PropertyChange> getChangedProperties(
    Configuration newConf, Configuration oldConf) {
  return reconfigurationUtil.parseChangedProperties(newConf, oldConf);
}
项目:hadoop-oss    文件:TestReconfiguration.java   
@Test
public void testAsyncReconfigure()
    throws ReconfigurationException, IOException, InterruptedException {
  AsyncReconfigurableDummy dummy = spy(new AsyncReconfigurableDummy(conf1));

  List<PropertyChange> changes = Lists.newArrayList();
  changes.add(new PropertyChange("name1", "new1", "old1"));
  changes.add(new PropertyChange("name2", "new2", "old2"));
  changes.add(new PropertyChange("name3", "new3", "old3"));
  doReturn(changes).when(dummy).getChangedProperties(
      any(Configuration.class), any(Configuration.class));

  doReturn(true).when(dummy).isPropertyReconfigurable(eq("name1"));
  doReturn(false).when(dummy).isPropertyReconfigurable(eq("name2"));
  doReturn(true).when(dummy).isPropertyReconfigurable(eq("name3"));

  doReturn("dummy").when(dummy)
      .reconfigurePropertyImpl(eq("name1"), anyString());
  doReturn("dummy").when(dummy)
      .reconfigurePropertyImpl(eq("name2"), anyString());
  doThrow(new ReconfigurationException("NAME3", "NEW3", "OLD3",
      new IOException("io exception")))
      .when(dummy).reconfigurePropertyImpl(eq("name3"), anyString());

  dummy.startReconfigurationTask();

  waitAsyncReconfigureTaskFinish(dummy);
  ReconfigurationTaskStatus status = dummy.getReconfigurationTaskStatus();
  assertEquals(2, status.getStatus().size());
  for (Map.Entry<PropertyChange, Optional<String>> result :
      status.getStatus().entrySet()) {
    PropertyChange change = result.getKey();
    if (change.prop.equals("name1")) {
      assertFalse(result.getValue().isPresent());
    } else if (change.prop.equals("name2")) {
      assertThat(result.getValue().get(),
          containsString("Property name2 is not reconfigurable"));
    } else if (change.prop.equals("name3")) {
      assertThat(result.getValue().get(), containsString("io exception"));
    } else {
      fail("Unknown property: " + change.prop);
    }
  }
}
项目:hadoop    文件:DFSAdmin.java   
int getReconfigurationStatus(String nodeType, String address,
    PrintStream out, PrintStream err) throws IOException {
  if ("datanode".equals(nodeType)) {
    ClientDatanodeProtocol dnProxy = getDataNodeProxy(address);
    try {
      ReconfigurationTaskStatus status = dnProxy.getReconfigurationStatus();
      out.print("Reconfiguring status for DataNode[" + address + "]: ");
      if (!status.hasTask()) {
        out.println("no task was found.");
        return 0;
      }
      out.print("started at " + new Date(status.getStartTime()));
      if (!status.stopped()) {
        out.println(" and is still running.");
        return 0;
      }

      out.println(" and finished at " +
          new Date(status.getEndTime()).toString() + ".");
      for (Map.Entry<PropertyChange, Optional<String>> result :
          status.getStatus().entrySet()) {
        if (!result.getValue().isPresent()) {
          out.print("SUCCESS: ");
        } else {
          out.print("FAILED: ");
        }
        out.printf("Change property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n",
            result.getKey().prop, result.getKey().oldVal,
            result.getKey().newVal);
        if (result.getValue().isPresent()) {
          out.println("\tError: " + result.getValue().get() + ".");
        }
      }
    } catch (IOException e) {
      err.println("DataNode reloading configuration: " + e + ".");
      return 1;
    }
  } else {
    err.println("Node type " + nodeType + " does not support reconfiguration.");
    return 1;
  }
  return 0;
}
项目:hadoop    文件:ReconfigurationTaskStatus.java   
public ReconfigurationTaskStatus(long startTime, long endTime,
    Map<ReconfigurationUtil.PropertyChange, Optional<String>> status) {
  this.startTime = startTime;
  this.endTime = endTime;
  this.status = status;
}
项目:hadoop    文件:ReconfigurationTaskStatus.java   
public final Map<PropertyChange, Optional<String>> getStatus() {
  return status;
}
项目:hadoop    文件:ReconfigurableBase.java   
@VisibleForTesting
public Collection<PropertyChange> getChangedProperties(
    Configuration newConf, Configuration oldConf) {
  return reconfigurationUtil.parseChangedProperties(newConf, oldConf);
}
项目:hadoop    文件:TestReconfiguration.java   
@Test
public void testAsyncReconfigure()
    throws ReconfigurationException, IOException, InterruptedException {
  AsyncReconfigurableDummy dummy = spy(new AsyncReconfigurableDummy(conf1));

  List<PropertyChange> changes = Lists.newArrayList();
  changes.add(new PropertyChange("name1", "new1", "old1"));
  changes.add(new PropertyChange("name2", "new2", "old2"));
  changes.add(new PropertyChange("name3", "new3", "old3"));
  doReturn(changes).when(dummy).getChangedProperties(
      any(Configuration.class), any(Configuration.class));

  doReturn(true).when(dummy).isPropertyReconfigurable(eq("name1"));
  doReturn(false).when(dummy).isPropertyReconfigurable(eq("name2"));
  doReturn(true).when(dummy).isPropertyReconfigurable(eq("name3"));

  doNothing().when(dummy)
      .reconfigurePropertyImpl(eq("name1"), anyString());
  doNothing().when(dummy)
      .reconfigurePropertyImpl(eq("name2"), anyString());
  doThrow(new ReconfigurationException("NAME3", "NEW3", "OLD3",
      new IOException("io exception")))
      .when(dummy).reconfigurePropertyImpl(eq("name3"), anyString());

  dummy.startReconfigurationTask();

  waitAsyncReconfigureTaskFinish(dummy);
  ReconfigurationTaskStatus status = dummy.getReconfigurationTaskStatus();
  assertEquals(3, status.getStatus().size());
  for (Map.Entry<PropertyChange, Optional<String>> result :
      status.getStatus().entrySet()) {
    PropertyChange change = result.getKey();
    if (change.prop.equals("name1")) {
      assertFalse(result.getValue().isPresent());
    } else if (change.prop.equals("name2")) {
      assertThat(result.getValue().get(),
          containsString("Property name2 is not reconfigurable"));
    } else if (change.prop.equals("name3")) {
      assertThat(result.getValue().get(), containsString("io exception"));
    } else {
      fail("Unknown property: " + change.prop);
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:DFSAdmin.java   
int getReconfigurationStatus(String nodeType, String address,
    PrintStream out, PrintStream err) throws IOException {
  if ("datanode".equals(nodeType)) {
    ClientDatanodeProtocol dnProxy = getDataNodeProxy(address);
    try {
      ReconfigurationTaskStatus status = dnProxy.getReconfigurationStatus();
      out.print("Reconfiguring status for DataNode[" + address + "]: ");
      if (!status.hasTask()) {
        out.println("no task was found.");
        return 0;
      }
      out.print("started at " + new Date(status.getStartTime()));
      if (!status.stopped()) {
        out.println(" and is still running.");
        return 0;
      }

      out.println(" and finished at " +
          new Date(status.getEndTime()).toString() + ".");
      if (status.getStatus() == null) {
        // Nothing to report.
        return 0;
      }
      for (Map.Entry<PropertyChange, Optional<String>> result :
          status.getStatus().entrySet()) {
        if (!result.getValue().isPresent()) {
          out.printf(
              "SUCCESS: Changed property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n",
              result.getKey().prop, result.getKey().oldVal,
              result.getKey().newVal);
        } else {
          final String errorMsg = result.getValue().get();
          out.printf(
                "FAILED: Change property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n",
                result.getKey().prop, result.getKey().oldVal,
                result.getKey().newVal);
          out.println("\tError: " + errorMsg + ".");
        }
      }
    } catch (IOException e) {
      err.println("DataNode reloading configuration: " + e + ".");
      return 1;
    }
  } else {
    err.println("Node type " + nodeType +
        " does not support reconfiguration.");
    return 1;
  }
  return 0;
}
项目:aliyun-oss-hadoop-fs    文件:ReconfigurationTaskStatus.java   
public ReconfigurationTaskStatus(long startTime, long endTime,
    Map<ReconfigurationUtil.PropertyChange, Optional<String>> status) {
  this.startTime = startTime;
  this.endTime = endTime;
  this.status = status;
}
项目:aliyun-oss-hadoop-fs    文件:ReconfigurationTaskStatus.java   
public final Map<PropertyChange, Optional<String>> getStatus() {
  return status;
}
项目:aliyun-oss-hadoop-fs    文件:ReconfigurableBase.java   
@VisibleForTesting
public Collection<PropertyChange> getChangedProperties(
    Configuration newConf, Configuration oldConf) {
  return reconfigurationUtil.parseChangedProperties(newConf, oldConf);
}
项目:aliyun-oss-hadoop-fs    文件:TestReconfiguration.java   
@Test
public void testAsyncReconfigure()
    throws ReconfigurationException, IOException, InterruptedException {
  AsyncReconfigurableDummy dummy = spy(new AsyncReconfigurableDummy(conf1));

  List<PropertyChange> changes = Lists.newArrayList();
  changes.add(new PropertyChange("name1", "new1", "old1"));
  changes.add(new PropertyChange("name2", "new2", "old2"));
  changes.add(new PropertyChange("name3", "new3", "old3"));
  doReturn(changes).when(dummy).getChangedProperties(
      any(Configuration.class), any(Configuration.class));

  doReturn(true).when(dummy).isPropertyReconfigurable(eq("name1"));
  doReturn(false).when(dummy).isPropertyReconfigurable(eq("name2"));
  doReturn(true).when(dummy).isPropertyReconfigurable(eq("name3"));

  doNothing().when(dummy)
      .reconfigurePropertyImpl(eq("name1"), anyString());
  doNothing().when(dummy)
      .reconfigurePropertyImpl(eq("name2"), anyString());
  doThrow(new ReconfigurationException("NAME3", "NEW3", "OLD3",
      new IOException("io exception")))
      .when(dummy).reconfigurePropertyImpl(eq("name3"), anyString());

  dummy.startReconfigurationTask();

  waitAsyncReconfigureTaskFinish(dummy);
  ReconfigurationTaskStatus status = dummy.getReconfigurationTaskStatus();
  assertEquals(2, status.getStatus().size());
  for (Map.Entry<PropertyChange, Optional<String>> result :
      status.getStatus().entrySet()) {
    PropertyChange change = result.getKey();
    if (change.prop.equals("name1")) {
      assertFalse(result.getValue().isPresent());
    } else if (change.prop.equals("name2")) {
      assertThat(result.getValue().get(),
          containsString("Property name2 is not reconfigurable"));
    } else if (change.prop.equals("name3")) {
      assertThat(result.getValue().get(), containsString("io exception"));
    } else {
      fail("Unknown property: " + change.prop);
    }
  }
}
项目:big-c    文件:DFSAdmin.java   
int getReconfigurationStatus(String nodeType, String address,
    PrintStream out, PrintStream err) throws IOException {
  if ("datanode".equals(nodeType)) {
    ClientDatanodeProtocol dnProxy = getDataNodeProxy(address);
    try {
      ReconfigurationTaskStatus status = dnProxy.getReconfigurationStatus();
      out.print("Reconfiguring status for DataNode[" + address + "]: ");
      if (!status.hasTask()) {
        out.println("no task was found.");
        return 0;
      }
      out.print("started at " + new Date(status.getStartTime()));
      if (!status.stopped()) {
        out.println(" and is still running.");
        return 0;
      }

      out.println(" and finished at " +
          new Date(status.getEndTime()).toString() + ".");
      for (Map.Entry<PropertyChange, Optional<String>> result :
          status.getStatus().entrySet()) {
        if (!result.getValue().isPresent()) {
          out.print("SUCCESS: ");
        } else {
          out.print("FAILED: ");
        }
        out.printf("Change property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n",
            result.getKey().prop, result.getKey().oldVal,
            result.getKey().newVal);
        if (result.getValue().isPresent()) {
          out.println("\tError: " + result.getValue().get() + ".");
        }
      }
    } catch (IOException e) {
      err.println("DataNode reloading configuration: " + e + ".");
      return 1;
    }
  } else {
    err.println("Node type " + nodeType + " does not support reconfiguration.");
    return 1;
  }
  return 0;
}
项目:big-c    文件:ReconfigurationTaskStatus.java   
public ReconfigurationTaskStatus(long startTime, long endTime,
    Map<ReconfigurationUtil.PropertyChange, Optional<String>> status) {
  this.startTime = startTime;
  this.endTime = endTime;
  this.status = status;
}
项目:big-c    文件:ReconfigurationTaskStatus.java   
public final Map<PropertyChange, Optional<String>> getStatus() {
  return status;
}
项目:big-c    文件:ReconfigurableBase.java   
@VisibleForTesting
public Collection<PropertyChange> getChangedProperties(
    Configuration newConf, Configuration oldConf) {
  return reconfigurationUtil.parseChangedProperties(newConf, oldConf);
}
项目:big-c    文件:TestReconfiguration.java   
@Test
public void testAsyncReconfigure()
    throws ReconfigurationException, IOException, InterruptedException {
  AsyncReconfigurableDummy dummy = spy(new AsyncReconfigurableDummy(conf1));

  List<PropertyChange> changes = Lists.newArrayList();
  changes.add(new PropertyChange("name1", "new1", "old1"));
  changes.add(new PropertyChange("name2", "new2", "old2"));
  changes.add(new PropertyChange("name3", "new3", "old3"));
  doReturn(changes).when(dummy).getChangedProperties(
      any(Configuration.class), any(Configuration.class));

  doReturn(true).when(dummy).isPropertyReconfigurable(eq("name1"));
  doReturn(false).when(dummy).isPropertyReconfigurable(eq("name2"));
  doReturn(true).when(dummy).isPropertyReconfigurable(eq("name3"));

  doNothing().when(dummy)
      .reconfigurePropertyImpl(eq("name1"), anyString());
  doNothing().when(dummy)
      .reconfigurePropertyImpl(eq("name2"), anyString());
  doThrow(new ReconfigurationException("NAME3", "NEW3", "OLD3",
      new IOException("io exception")))
      .when(dummy).reconfigurePropertyImpl(eq("name3"), anyString());

  dummy.startReconfigurationTask();

  waitAsyncReconfigureTaskFinish(dummy);
  ReconfigurationTaskStatus status = dummy.getReconfigurationTaskStatus();
  assertEquals(3, status.getStatus().size());
  for (Map.Entry<PropertyChange, Optional<String>> result :
      status.getStatus().entrySet()) {
    PropertyChange change = result.getKey();
    if (change.prop.equals("name1")) {
      assertFalse(result.getValue().isPresent());
    } else if (change.prop.equals("name2")) {
      assertThat(result.getValue().get(),
          containsString("Property name2 is not reconfigurable"));
    } else if (change.prop.equals("name3")) {
      assertThat(result.getValue().get(), containsString("io exception"));
    } else {
      fail("Unknown property: " + change.prop);
    }
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:DFSAdmin.java   
int getReconfigurationStatus(String nodeType, String address,
    PrintStream out, PrintStream err) throws IOException {
  if ("datanode".equals(nodeType)) {
    ClientDatanodeProtocol dnProxy = getDataNodeProxy(address);
    try {
      ReconfigurationTaskStatus status = dnProxy.getReconfigurationStatus();
      out.print("Reconfiguring status for DataNode[" + address + "]: ");
      if (!status.hasTask()) {
        out.println("no task was found.");
        return 0;
      }
      out.print("started at " + new Date(status.getStartTime()));
      if (!status.stopped()) {
        out.println(" and is still running.");
        return 0;
      }

      out.println(" and finished at " +
          new Date(status.getEndTime()).toString() + ".");
      for (Map.Entry<PropertyChange, Optional<String>> result :
          status.getStatus().entrySet()) {
        if (!result.getValue().isPresent()) {
          out.print("SUCCESS: ");
        } else {
          out.print("FAILED: ");
        }
        out.printf("Change property %s\n\tFrom: \"%s\"\n\tTo: \"%s\"\n",
            result.getKey().prop, result.getKey().oldVal,
            result.getKey().newVal);
        if (result.getValue().isPresent()) {
          out.println("\tError: " + result.getValue().get() + ".");
        }
      }
    } catch (IOException e) {
      err.println("DataNode reloading configuration: " + e + ".");
      return 1;
    }
  } else {
    err.println("Node type " + nodeType + " does not support reconfiguration.");
    return 1;
  }
  return 0;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ReconfigurationTaskStatus.java   
public ReconfigurationTaskStatus(long startTime, long endTime,
    Map<ReconfigurationUtil.PropertyChange, Optional<String>> status) {
  this.startTime = startTime;
  this.endTime = endTime;
  this.status = status;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ReconfigurationTaskStatus.java   
public final Map<PropertyChange, Optional<String>> getStatus() {
  return status;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ReconfigurableBase.java   
@VisibleForTesting
public Collection<PropertyChange> getChangedProperties(
    Configuration newConf, Configuration oldConf) {
  return reconfigurationUtil.parseChangedProperties(newConf, oldConf);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestReconfiguration.java   
@Test
public void testAsyncReconfigure()
    throws ReconfigurationException, IOException, InterruptedException {
  AsyncReconfigurableDummy dummy = spy(new AsyncReconfigurableDummy(conf1));

  List<PropertyChange> changes = Lists.newArrayList();
  changes.add(new PropertyChange("name1", "new1", "old1"));
  changes.add(new PropertyChange("name2", "new2", "old2"));
  changes.add(new PropertyChange("name3", "new3", "old3"));
  doReturn(changes).when(dummy).getChangedProperties(
      any(Configuration.class), any(Configuration.class));

  doReturn(true).when(dummy).isPropertyReconfigurable(eq("name1"));
  doReturn(false).when(dummy).isPropertyReconfigurable(eq("name2"));
  doReturn(true).when(dummy).isPropertyReconfigurable(eq("name3"));

  doNothing().when(dummy)
      .reconfigurePropertyImpl(eq("name1"), anyString());
  doNothing().when(dummy)
      .reconfigurePropertyImpl(eq("name2"), anyString());
  doThrow(new ReconfigurationException("NAME3", "NEW3", "OLD3",
      new IOException("io exception")))
      .when(dummy).reconfigurePropertyImpl(eq("name3"), anyString());

  dummy.startReconfigurationTask();

  waitAsyncReconfigureTaskFinish(dummy);
  ReconfigurationTaskStatus status = dummy.getReconfigurationTaskStatus();
  assertEquals(3, status.getStatus().size());
  for (Map.Entry<PropertyChange, Optional<String>> result :
      status.getStatus().entrySet()) {
    PropertyChange change = result.getKey();
    if (change.prop.equals("name1")) {
      assertFalse(result.getValue().isPresent());
    } else if (change.prop.equals("name2")) {
      assertThat(result.getValue().get(),
          containsString("Property name2 is not reconfigurable"));
    } else if (change.prop.equals("name3")) {
      assertThat(result.getValue().get(), containsString("io exception"));
    } else {
      fail("Unknown property: " + change.prop);
    }
  }
}