Refresh an index
@param index index name
@throws IOException In case of error
542076
public void refresh(String index) throws IOException {
        logger.debug("refresh index [{}]", index);
        RefreshRequest request = new RefreshRequest();
        if (!isNullOrEmpty(index)) {
            request.indices(index);
        }
        RefreshResponse refresh = client.indices().refresh(request, RequestOptions.DEFAULT);
        logger.trace("refresh response: {}", refresh);
    }
356465
public void setLastApplied(long index) {
    // Query callbacks for this session are added to the indexQueries map to be executed once the required index
    // for the query is reached. For each increment of the index, trigger query callbacks that are dependent
    // on the specific index.
    for (long i = lastApplied + 1; i <= index; i++) {
      lastApplied = i;
      List<Runnable> queries = this.indexQueries.remove(lastApplied);
      if (queries != null) {
        for (Runnable query : queries) {
          query.run();
        }
      }
    }
  }
1191521
private void addIndex(final String index) throws IOException {

        logger.info("Adding index '{}'...", index);

        String resourcePath = "/" + index;

        if (doesResourceNotExist(resourcePath)) {

            try {
                elasticSearchAdminClient.performRequest(HttpMethod.PUT, resourcePath);

                logger.info("Added '{}' index", index);
            } catch (ResponseException e) {

                boolean errorCreatingIndex = true;

                Response errorResponse = e.getResponse();
                if (errorResponse.getStatusLine().getStatusCode() == HttpStatus.SC_BAD_REQUEST) {
                    JsonNode root = objectMapper.readTree(EntityUtils.toString(errorResponse.getEntity()));
                    String errorCode = root.get("error").get("type").asText();
                    if ("index_already_exists_exception".equals(errorCode)) {
                        errorCreatingIndex = false;
                    }
                }

                if (errorCreatingIndex) {
                    throw e;
                }
            }
        } else {
            logger.info("Index '{}' already exists", index);
        }
    }
32856
public void clearIndex(Index index) {
    BulkIndexer.delete(esClient, IndexType.main(index, index.getName()), esClient.prepareSearch(index).setQuery(matchAllQuery()));
  }
798283
public void setValue(int index, int value) throws IOException {
        if (index >= structure.valueSizes.size()) {
            throw new IOException("Index " + index + " is out of range.");
        }
        Bytes.putInt(this.value, structure.valueByteOffsets.get(index), value);
    }
304650
private void rename(String from, String to) throws IOException
   {
      IndexOutputStream out = null;
      IndexInputStream in = null;
      try
      {
         out = new IndexOutputStream(dir.createOutput(to));
         in = new IndexInputStream(dir.openInput(from));
         DirectoryHelper.transfer(in, out);
      }
      finally
      {
         if (in != null)
         {
            in.close();
         }

         if (out != null)
         {
            out.flush();
            out.close();
         }
      }
      try
      {
         // delete old one
         if (dir.fileExists(from))
         {
            dir.deleteFile(from);
         }
      }
      catch (IOException e)
      {
         // do noting. Will be removed later
         if (LOG.isTraceEnabled())
         {
            LOG.trace("Can't deleted file: " + e.getMessage());
         }
      }
   }
468045
public static void refresh()
    {
        try
        {
            setContext(prop);
        }
        catch (NamingException e)
        {
            log.error("Unable to refresh the naming context");
            throw new OJBRuntimeException("Refresh of context failed, used properties: "
                    + (prop != null ? prop.toString() : "none"), e);
        }
    }
570571
@SuppressWarnings("unchecked")
  private void applyIndex(long index) {
    // Apply entries prior to this entry.
    if (reader.hasNext() && reader.getNextIndex() == index) {
      // Read the entry from the log. If the entry is non-null then apply it, otherwise
      // simply update the last applied index and return a null result.
      Indexed<RaftLogEntry> entry = reader.next();
      try {
        if (entry.index() != index) {
          throw new IllegalStateException("inconsistent index applying entry " + index + ": " + entry);
        }
        CompletableFuture future = futures.remove(index);
        apply(entry).whenComplete((r, e) -> {
          raft.setLastApplied(index);
          if (future != null) {
            if (e == null) {
              future.complete(r);
            } else {
              future.completeExceptionally(e);
            }
          }
        });
      } catch (Exception e) {
        logger.error("Failed to apply {}: {}", entry, e);
      }
    } else {
      CompletableFuture future = futures.remove(index);
      if (future != null) {
        logger.error("Cannot apply index " + index);
        future.completeExceptionally(new IndexOutOfBoundsException("Cannot apply index " + index));
      }
    }
  }
347661
public void deselectByIndex(int index) {
        getDispatcher().beforeDeselect(this, index);
        
        new Select(getElement()).deselectByIndex(index);
        if (Config.getBoolConfigProperty(ConfigProperty.ENABLE_GUI_LOGGING)) {
            logUIActions(UIActions.CLEARED, Integer.toString(index));
        }
        
        getDispatcher().afterDeselect(this, index);
    }
351554
protected synchronized void indexSearcherUpdate() {

        IndexSearcher oldSearcher = m_indexSearcher;
        if ((oldSearcher != null) && (oldSearcher.getIndexReader() != null)) {
            // in case there is an index searcher available close it
            try {
                if (oldSearcher.getIndexReader() instanceof DirectoryReader) {
                    IndexReader newReader = DirectoryReader.openIfChanged(
                        (DirectoryReader)oldSearcher.getIndexReader());
                    if (newReader != null) {
                        m_indexSearcher = new IndexSearcher(newReader);
                        m_indexSearcher.setSimilarity(m_sim);
                        indexSearcherClose(oldSearcher);
                    }
                }
            } catch (Exception e) {
                LOG.error(Messages.get().getBundle().key(Messages.ERR_INDEX_SEARCHER_REOPEN_1, getName()), e);
            }
        } else {
            // make sure we end up with an open index searcher / reader
            indexSearcherOpen(getPath());
        }
    }
860745
protected void handleLoadIndex(String indexLocation) {
        reportable.output("Loading resource from index file:");
        reportable.output("  " + indexLocation);

        File indexFile = new File(indexLocation);
        if (!indexFile.exists() || !indexFile.canRead()) {
            // try the index as an online resource.
            try {
                ResolvedResource resolvedResource = cacheService
                        .resolveResource(ResourceType.RESOURCE_INDEX,
                                indexLocation);
                indexFile = resolvedResource.getCacheResourceCopy();
            } catch (Exception e) {
                reportable.error("Index could not be read");
                bail(GENERAL_FAILURE);
            }
        }

        try {
            ResourceIndex.INSTANCE.loadIndex(indexFile);
        } catch (Exception e) {
            reportable.error("Unable to load index");
            reportable.error("Reason: " + e.getMessage());
            bail(GENERAL_FAILURE);
        }

        Index index = ResourceIndex.INSTANCE.getIndex();
        cacheMgrService.updateResourceIndexInCache(index);
    }
746210
public void waitForHealthyIndex(String index) throws IOException {
        logger.debug("wait for yellow health on index [{}]", index);
        ClusterHealthResponse health = client.cluster().health(new ClusterHealthRequest(index).waitForYellowStatus(),
                RequestOptions.DEFAULT);
        logger.trace("health response: {}", health);
    }
1326317
protected void refreshIndexes(Set<String> set)
   {
      // do nothing if null is passed
      if (set == null)
      {
         return;
      }
      setNames(set);
      // callback multiIndex to refresh lists
      try
      {
         MultiIndex multiIndex = getMultiIndex();
         if (multiIndex != null)
         {
            multiIndex.refreshIndexList();
         }
      }
      catch (IOException e)
      {
         LOG.error("Failed to update indexes! " + e.getMessage(), e);
      }
   }
1056020
@Override
    public void refreshAllIndexes() throws QueryException {
        List<Index> indexes = listIndexes();

        IndexUpdater.updateAllIndexes(indexes, database, dbQueue);
    }
71869
private void refreshFileList()
      throws IOException {
    FileStatus[] files = fileSystem.globStatus(inputDirectoryAndPattern);
    for (FileStatus file : files) {
      String fileName = file.getPath().getName();
      if (!knownFileSet.contains(fileName)) {
        if (endFileNumber != -1) {
          // Sanity check against endFileNumber.
          int newFileIndex = parseFileIndex(fileName);
          Preconditions.checkState(newFileIndex < endFileNumber,
              "Found new file '%s' with index %s, which isn't less than endFileNumber %s!",
              fileName, newFileIndex, endFileNumber);
        }

        logger.atInfo().log(
            "Adding new file '%s' of size %s to knownFileSet.", fileName, file.getLen());
        knownFileSet.add(fileName);
        fileQueue.add(file);
      }
    }
  }
132998
private void resetVolatileIndex() throws IOException
   {
      volatileIndex = new VolatileIndex(handler.getTextAnalyzer(), handler.getSimilarity());
      volatileIndex.setUseCompoundFile(handler.getUseCompoundFile());
      volatileIndex.setMaxFieldLength(handler.getMaxFieldLength());
      volatileIndex.setBufferSize(handler.getBufferSize());
   }
850182
public function setIndex($index)
    {
        if ($this->index !== $index) {
            $this->index = $index;
            $this->addOrUpdate();
        }
    }