• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PropertyChange类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange的典型用法代码示例。如果您正苦于以下问题:Java PropertyChange类的具体用法?Java PropertyChange怎么用?Java PropertyChange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PropertyChange类属于org.apache.hadoop.conf.ReconfigurationUtil包,在下文中一共展示了PropertyChange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getReconfigurationStatus

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
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);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:26,代码来源:ReconfigurationProtocolUtils.java


示例2: run

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
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;
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:40,代码来源:ReconfigurableBase.java


示例3: testGetChangedProperties

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:32,代码来源:TestReconfiguration.java


示例4: getReconfigurationStatus

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
@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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:ClientDatanodeProtocolTranslatorPB.java


示例5: run

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
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;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:ReconfigurableBase.java


示例6: run

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
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;
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:34,代码来源:ReconfigurableBase.java


示例7: ReconfigurationTaskStatus

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
public ReconfigurationTaskStatus(long startTime, long endTime,
    Map<ReconfigurationUtil.PropertyChange, Optional<String>> status) {
  this.startTime = startTime;
  this.endTime = endTime;
  this.status = status;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:7,代码来源:ReconfigurationTaskStatus.java


示例8: getStatus

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
public final Map<PropertyChange, Optional<String>> getStatus() {
  return status;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:4,代码来源:ReconfigurationTaskStatus.java


示例9: getChangedProperties

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
@VisibleForTesting
public Collection<PropertyChange> getChangedProperties(
    Configuration newConf, Configuration oldConf) {
  return reconfigurationUtil.parseChangedProperties(newConf, oldConf);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:6,代码来源:ReconfigurableBase.java


示例10: testAsyncReconfigure

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:45,代码来源:TestReconfiguration.java


示例11: getReconfigurationStatus

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:44,代码来源:DFSAdmin.java


示例12: testAsyncReconfigure

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:45,代码来源:TestReconfiguration.java


示例13: getReconfigurationStatus

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
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;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:51,代码来源:DFSAdmin.java


示例14: testAsyncReconfigure

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:45,代码来源:TestReconfiguration.java


示例15: getReconfigurationStatus

import org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange; //导入依赖的package包/类
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;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:44,代码来源:DFSAdmin.java



注:本文中的org.apache.hadoop.conf.ReconfigurationUtil.PropertyChange类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Constants类代码示例发布时间:2022-05-23
下一篇:
Java ServiceList类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap