/** @param viewDistance */
 private void setDynamicViewDistance(RenderDistance distance) {
   int lastDistance = serverDistance;
   if (distance.getValue() < serverDistance) {
     lastDistance = distance.getValue();
   }
   Reflection.field("e").ofType(int.class).in(this).set(lastDistance);
 }
示例#2
0
  @Implementation
  public void layout(int l, int t, int r, int b) {
    if (l != left || r != right || t != top || b != bottom) {
      left = l;
      top = t;
      right = r;
      bottom = b;

      realView.invalidate();
      Reflection.method("onLayout")
          .withParameterTypes(boolean.class, int.class, int.class, int.class, int.class)
          .in(realView)
          .invoke(true, l, t, r, b);
    }
  }
  /** @param instance */
  public RockyPlayerServerManager(PlayerChunkMap instance) {
    super(Reflection.field("world").ofType(WorldServer.class).in(instance).get(), 3);

    serverDistance = Reflection.field("e").ofType(int.class).in(instance).get();

    Reflection.field("managedPlayers")
        .ofType(List.class)
        .in(this)
        .set(Reflection.field("managedPlayers").ofType(List.class).in(instance).get());
    Reflection.field("c")
        .ofType(LongHashMap.class)
        .in(this)
        .set(Reflection.field("c").ofType(LongHashMap.class).in(instance).get());
    Reflection.field("d")
        .ofType(Queue.class)
        .in(this)
        .set(Reflection.field("d").ofType(Queue.class).in(instance).get());
  }
 private void setRunning(MessageQueue mq) {
   Reflection.field("running").ofType(AtomicBoolean.class).in(mq).get().set(true);
 }
示例#5
0
  public static HiveServer create(
      Map<String, String> properties,
      File baseDir,
      File confDir,
      File logDir,
      FileSystem fileSystem)
      throws Exception {

    if (!properties.containsKey(WAREHOUSE_DIR)) {
      LOGGER.info("fileSystem " + fileSystem.getClass().getSimpleName());
      if (fileSystem instanceof DistributedFileSystem) {
        String dfsUri = FileSystem.getDefaultUri(fileSystem.getConf()).toString();
        LOGGER.info("dfsUri " + dfsUri);
        properties.put(WAREHOUSE_DIR, dfsUri + "/data");
        fileSystem.mkdirs(new Path("/data/"), new FsPermission((short) 0777));
      } else {
        properties.put(WAREHOUSE_DIR, new File(baseDir, "warehouse").getPath());
        fileSystem.mkdirs(new Path("/", "warehouse"), new FsPermission((short) 0777));
      }
    }
    LOGGER.info("Setting an readable path to hive.exec.scratchdir");
    properties.put("hive.exec.scratchdir", new File(baseDir, "scratchdir").getPath());

    if (!properties.containsKey(METASTORE_CONNECTION_URL)) {
      properties.put(
          METASTORE_CONNECTION_URL,
          String.format(
              "jdbc:derby:;databaseName=%s;create=true", new File(baseDir, "metastore").getPath()));
    }
    if (!properties.containsKey(HS2_PORT)) {
      properties.put(HS2_PORT, String.valueOf(findPort()));
    }
    if (!properties.containsKey(SUPPORT_CONCURRENCY)) {
      properties.put(SUPPORT_CONCURRENCY, "false");
    }
    if (!properties.containsKey(HADOOPBIN)) {
      properties.put(HADOOPBIN, "./target/test-classes/hadoop");
    }

    // Modify the test resource to have executable permission
    java.nio.file.Path hadoopPath =
        FileSystems.getDefault().getPath("target/test-classes", "hadoop");
    if (hadoopPath != null) {
      hadoopPath.toFile().setExecutable(true);
    }

    properties.put(METASTORE_SETUGI, "true");
    properties.put(METASTORE_CLIENT_TIMEOUT, "100");
    properties.put(ConfVars.HIVE_WAREHOUSE_SUBDIR_INHERIT_PERMS.varname, "true");

    properties.put(ConfVars.HIVESTATSAUTOGATHER.varname, "false");
    properties.put(ConfVars.HIVE_STATS_COLLECT_SCANCOLS.varname, "true");
    String hadoopBinPath = properties.get(HADOOPBIN);
    Assert.assertNotNull(hadoopBinPath, "Hadoop Bin");
    File hadoopBin = new File(hadoopBinPath);
    if (!hadoopBin.isFile()) {
      Assert.fail(
          "Path to hadoop bin "
              + hadoopBin.getPath()
              + " is invalid. "
              + "Perhaps you missed the download-hadoop profile.");
    }

    /*
     * This hack, setting the hiveSiteURL field removes a previous hack involving
     * setting of system properties for each property. Although both are hacks,
     * I prefer this hack because once the system properties are set they can
     * affect later tests unless those tests clear them. This hack allows for
     * a clean switch to a new set of defaults when a new HiveConf object is created.
     */
    Reflection.staticField("hiveSiteURL").ofType(URL.class).in(HiveConf.class).set(null);
    HiveConf hiveConf = new HiveConf();
    for (Map.Entry<String, String> entry : properties.entrySet()) {
      LOGGER.info(entry.getKey() + " => " + entry.getValue());
      hiveConf.set(entry.getKey(), entry.getValue());
    }
    File hiveSite = new File(confDir, "hive-site.xml");

    hiveConf.set(HIVESERVER2_IMPERSONATION, "false");
    OutputStream out = new FileOutputStream(hiveSite);
    hiveConf.writeXml(out);
    out.close();

    Reflection.staticField("hiveSiteURL")
        .ofType(URL.class)
        .in(HiveConf.class)
        .set(hiveSite.toURI().toURL());

    LOGGER.info("Creating InternalHiveServer");
    return new InternalHiveServer(hiveConf);
  }
 /**
  * Sets the metadata of the entity
  *
  * @param metadata the metadata of the entity
  */
 public void setMetadata(List<WatchableObject> metadata) {
   Reflection.field("b").ofType(List.class).in(packet).set(metadata);
 }
 /** Gets the data of the entity */
 @SuppressWarnings("unchecked")
 public List<WatchableObject> getMetadata() {
   return (List<WatchableObject>) Reflection.field("b").ofType(List.class).in(packet).get();
 }