@AfterClass
  public static void tearDownTestStaticConfiguration() throws Exception {
    if (hiveServer != null) {
      hiveServer.shutdown();
      hiveServer = null;
    }

    if (sentryServer != null) {
      sentryServer.close();
      sentryServer = null;
    }

    if (baseDir != null) {
      if (System.getProperty(HiveServerFactory.KEEP_BASEDIR) == null) {
        FileUtils.deleteQuietly(baseDir);
      }
      baseDir = null;
    }
    if (dfs != null) {
      try {
        dfs.tearDown();
      } catch (Exception e) {
        LOGGER.info("Exception shutting down dfs", e);
      }
    }
    if (context != null) {
      context.close();
    }
  }
コード例 #2
0
  public void rename(Name name, Name newName) throws NamingException {
    if (name.size() == 1) {
      if (newName.size() != 1) {
        throw new OperationNotSupportedException(
            "Renaming to a Name with more components not supported: " + newName);
      }
      rename(name.get(0), newName.get(0));
    } else {
      // > 1 component with 1st one being URL
      // URLs must be identical; cannot deal with diff URLs
      if (!urlEquals(name.get(0), newName.get(0))) {
        throw new OperationNotSupportedException(
            "Renaming using different URLs as first components not supported: "
                + name
                + " "
                + newName);
      }

      Context ctx = getContinuationContext(name);
      try {
        ctx.rename(name.getSuffix(1), newName.getSuffix(1));
      } finally {
        ctx.close();
      }
    }
  }
コード例 #3
0
 public NameParser getNameParser(String name) throws NamingException {
   ResolveResult res = getRootURLContext(name, myEnv);
   Context ctx = (Context) res.getResolvedObj();
   try {
     return ctx.getNameParser(res.getRemainingName());
   } finally {
     ctx.close();
   }
 }
コード例 #4
0
 public void rebind(String name, Object obj) throws NamingException {
   ResolveResult res = getRootURLContext(name, myEnv);
   Context ctx = (Context) res.getResolvedObj();
   try {
     ctx.rebind(res.getRemainingName(), obj);
   } finally {
     ctx.close();
   }
 }
コード例 #5
0
 public void destroySubcontext(String name) throws NamingException {
   ResolveResult res = getRootURLContext(name, myEnv);
   Context ctx = (Context) res.getResolvedObj();
   try {
     ctx.destroySubcontext(res.getRemainingName());
   } finally {
     ctx.close();
   }
 }
コード例 #6
0
 public NamingEnumeration listBindings(String name) throws NamingException {
   ResolveResult res = getRootURLContext(name, myEnv);
   Context ctx = (Context) res.getResolvedObj();
   try {
     return ctx.listBindings(res.getRemainingName());
   } finally {
     ctx.close();
   }
 }
コード例 #7
0
ファイル: MediaDriver.java プロジェクト: AAyyy/Aeron
  /** Shutdown the media driver by stopping all threads and freeing resources. */
  public void close() {
    try {
      runners.forEach(AgentRunner::close);

      freeSocketsForReuseOnWindows();
      ctx.close();
    } catch (final Exception ex) {
      LangUtil.rethrowUnchecked(ex);
    }
  }
コード例 #8
0
 public NameParser getNameParser(Name name) throws NamingException {
   if (name.size() == 1) {
     return getNameParser(name.get(0));
   } else {
     Context ctx = getContinuationContext(name);
     try {
       return ctx.getNameParser(name.getSuffix(1));
     } finally {
       ctx.close();
     }
   }
 }
コード例 #9
0
 public Object lookupLink(Name name) throws NamingException {
   if (name.size() == 1) {
     return lookupLink(name.get(0));
   } else {
     Context ctx = getContinuationContext(name);
     try {
       return ctx.lookupLink(name.getSuffix(1));
     } finally {
       ctx.close();
     }
   }
 }
コード例 #10
0
 public void destroySubcontext(Name name) throws NamingException {
   if (name.size() == 1) {
     destroySubcontext(name.get(0));
   } else {
     Context ctx = getContinuationContext(name);
     try {
       ctx.destroySubcontext(name.getSuffix(1));
     } finally {
       ctx.close();
     }
   }
 }
コード例 #11
0
 public NamingEnumeration listBindings(Name name) throws NamingException {
   if (name.size() == 1) {
     return listBindings(name.get(0));
   } else {
     Context ctx = getContinuationContext(name);
     try {
       return ctx.listBindings(name.getSuffix(1));
     } finally {
       ctx.close();
     }
   }
 }
コード例 #12
0
 @Override
 public void process(Workflow workflow) throws IOException {
   OutputStream output = getEnvironment().openResource(PATH);
   try {
     Context context = new Context(output);
     dumpEnv(context);
     dumpSystemProperties(context);
     context.close();
   } finally {
     output.close();
   }
 }
コード例 #13
0
 public void rebind(Name name, Object obj) throws NamingException {
   if (name.size() == 1) {
     rebind(name.get(0), obj);
   } else {
     Context ctx = getContinuationContext(name);
     try {
       ctx.rebind(name.getSuffix(1), obj);
     } finally {
       ctx.close();
     }
   }
 }
コード例 #14
0
 public Context createSubcontext(Name name) throws NamingException {
   if (name.size() == 1) {
     return createSubcontext(name.get(0));
   } else {
     Context ctx = getContinuationContext(name);
     try {
       return ctx.createSubcontext(name.getSuffix(1));
     } finally {
       ctx.close();
     }
   }
 }
コード例 #15
0
  /**
   * Runs the example code.
   *
   * @param args (ignored) command-line arguments
   * @throws BaseXException if a database command fails
   */
  public static void main(final String[] args) throws BaseXException {
    // Create database context
    Context context = new Context();

    System.out.println("=== CreateCollection ===");

    // ------------------------------------------------------------------------
    // You can modify the CREATEFILTER property to import XML
    // files with suffixes other than XML (for example KML):
    new Set("CREATEFILTER", "*.xml").execute(context);

    // Variant 1 --------------------------------------------------------------
    // Create a collection and add all documents within the specified path
    System.out.println("\n* Create a collection.");

    new CreateDB("Collection", "src/main/resources/").execute(context);
    new DropDB("Collection").execute(context);

    // Variant 2 --------------------------------------------------------------
    // Or: Create an empty collection, add documents in a second pass
    // and optimize the database to refresh the index structures
    System.out.println("\n* Create an empty collection and add documents.");

    new CreateDB("Collection").execute(context);
    new Add("", "src/main/resources/").execute(context);
    new Optimize().execute(context);

    // ------------------------------------------------------------------------
    // Remove a single document from the collection
    System.out.println("\n* Remove a single document.");

    new Delete("test.xml").execute(context);

    // ------------------------------------------------------------------------
    // Show information on the currently opened database
    System.out.println("\n* Show database information:");

    System.out.println(new InfoDB().execute(context));

    // ------------------------------------------------------------------------
    // Drop the database
    System.out.println("\n* Drop the collection.");

    new DropDB("Collection").execute(context);

    // ------------------------------------------------------------------------
    // Close the database context
    context.close();
  }
コード例 #16
0
  public void rename(String oldName, String newName) throws NamingException {
    String oldPrefix = getURLPrefix(oldName);
    String newPrefix = getURLPrefix(newName);
    if (!urlEquals(oldPrefix, newPrefix)) {
      throw new OperationNotSupportedException(
          "Renaming using different URL prefixes not supported : " + oldName + " " + newName);
    }

    ResolveResult res = getRootURLContext(oldName, myEnv);
    Context ctx = (Context) res.getResolvedObj();
    try {
      ctx.rename(res.getRemainingName(), getURLSuffix(newPrefix, newName));
    } finally {
      ctx.close();
    }
  }
コード例 #17
0
ファイル: BindVariables.java プロジェクト: LukasK/basex
  /**
   * Runs the example code.
   *
   * @param args (ignored) command-line arguments
   * @throws QueryException if an error occurs while evaluating the query
   */
  public static void main(final String[] args) throws QueryException {
    // Database context.
    Context context = new Context();

    System.out.println("=== BindVariable ===");

    // Specify query to be executed
    String query =
        "declare variable $var1 as xs:string external;\n"
            + "declare variable $var2 external;\n"
            + "($var1, $var2)";

    // Show query
    System.out.println("\n* Query:");
    System.out.println(query);

    // Create a query processor
    try (QueryProcessor proc = new QueryProcessor(query, context)) {

      // Define the items to be bound
      String string = "Hello World!\n";
      String number = "123";

      // Bind the variables
      proc.bind("var1", string);
      proc.bind("var2", number, "xs:integer");

      // Execute the query
      Result result = proc.execute();

      System.out.println("\n* Result:");

      // ------------------------------------------------------------------------
      // Print result as string
      System.out.println(result);
    }

    // ------------------------------------------------------------------------
    // Close the database context
    context.close();
  }
コード例 #18
0
 public void close() throws NamingException {
   ctx.close();
 }
コード例 #19
0
ファイル: FTIndexQueryTest.java プロジェクト: alpheios/basex
 /** Static clean-up. */
 @AfterClass
 public static void cleanUpClass() {
   CTX_IX.close();
 }