code: public synchronized void setOnline(boolean isOnline, boolean dropStaleIndexes, boolean initMerger) throws IOException
     {
        // if mode really changed
        if (online.get() != isOnline)
        {
           // switching to ONLINE
           if (isOnline)
           {
              LOG.info("Setting index ONLINE ({})", handler.getContext().getWorkspacePath(true));
              if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
              {
                 offlineIndex.commit(true);
                 online.set(true);
                 // cleaning stale indexes
                 for (PersistentIndex staleIndex : staleIndexes)
                 {
                    deleteIndex(staleIndex);
                 }
                 //invoking offline index
                 invokeOfflineIndex();
                 staleIndexes.clear();
                 if(initMerger)
                 {
                    initMerger();
                 }
              }
              else
              {
                 online.set(true);
                 staleIndexes.clear();
              }
           }
           // switching to OFFLINE
           else
           {
              LOG.info("Setting index OFFLINE ({})", handler.getContext().getWorkspacePath(true));
              if (initMerger && merger != null)
              {
                 merger.dispose();
                 merger = null;
              }
              offlineIndex =
                 new OfflinePersistentIndex(handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager,
                    modeHandler);
              if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
              {
                 flush();
              }
              releaseMultiReader();
              if (dropStaleIndexes)
              {
                 staleIndexes.addAll(indexes);
              }
  
              online.set(false);
           }
        }
        else if (!online.get())
        {
           throw new IOException("Index is already in OFFLINE mode.");
        }
     }
docs: Switches index mode
  
  @param isOnline
  @throws IOException