Package com.splunk

Examples of com.splunk.Index


                Command.error("Index " + name + " already exists");
            indexes.create(name);
            return;
        }

        Index index = indexes.get(name);
        if (index == null)
            Command.error("Index '" + name + "' does not exists");

        if (action.equals("clean")) {
            try {
                index.clean(180);   // Timeout after 3 minutes.
            } catch (SplunkException e) {
                if (e.getCode() == SplunkException.INTERRUPTED) {
                    // User pressed Ctrl-C
                    return;
                } else {
                    throw e;
                }
            }
        }
        else if (action.equals("disable"))
            index.disable();
        else if (action.equals("enable"))
            index.enable();
        else
            Command.error("Unknown action '" + action + "'");
    }
View Full Code Here


        super(endpoint, args);
    }

    @Override
    protected void doWrite(SplunkEvent event) throws IOException {
        Index index = getIndex();
        if (index != null) {
            index.submit(args, event.toString());
        } else {
            Receiver receiver = endpoint.getService().getReceiver();
            receiver.submit(args, event.toString());
        }
    }
View Full Code Here

        this.index = index;
    }

    @Override
    protected Socket createSocket(Service service) throws IOException {
        Index indexObject = null;
        Receiver receiver = null;
        Socket socket = null;

        if (index != null) {
            indexObject = service.getIndexes().get(index);
            if (indexObject == null) {
                throw new RuntimeCamelException(String.format("cannot find index [%s]", index));
            }
            socket = indexObject.attach(args);
        } else {
            receiver = service.getReceiver();
            socket = receiver.attach(args);
        }
        socket.setTcpNoDelay(true);
View Full Code Here

        setConnectionFactory(new MockConnectionFactory(service));
    }

    private void mockSplunkWriterApi() {
        try {
            Index index = mock(Index.class);
            IndexCollection indexColl = mock(IndexCollection.class);
            when(service.getIndexes()).thenReturn(indexColl);
            InputCollection inputCollection = mock(InputCollection.class);
            when(service.getInputs()).thenReturn(inputCollection);
            Input input = mock(Input.class);
            when(service.open(anyInt())).thenReturn(socket);
            when(inputCollection.get(anyString())).thenReturn(input);
            when(indexColl.get(anyString())).thenReturn(index);
            when(index.attach(isA(Args.class))).thenReturn(socket);
            when(socket.getOutputStream()).thenReturn(System.out);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

   * @return thaw location for specified index.
   * @throws IllegalIndexException
   *           if index does not exist in splunk
   */
  public File getThawLocation(String index) throws IllegalIndexException {
    Index splunkIndex = getIndexChecked(index);
    return new File(splunkIndex.getThawedPathExpanded());
  }
View Full Code Here

    Index splunkIndex = getIndexChecked(index);
    return new File(splunkIndex.getThawedPathExpanded());
  }

  private Index getIndexChecked(String index) {
    Index splunkIndex = getIndexes().get(index);
    if (splunkIndex == null)
      throwAndLogNonExistingSplunkIndex(index);
    return splunkIndex;
  }
View Full Code Here

  /**
   * @return iterable over buckets in a cold buckets directory for a specified
   *         index.
   */
  public Iterable<LocalBucket> coldBucketsAtIndex(String indexName) {
    Index splunkIndex = getSplunkIndexByName(indexName);
    String coldPath = splunkIndex.getColdPathExpanded();
    return bucketIteratorFactory.iteratorInDirectory(new File(coldPath),
        indexName);
  }
View Full Code Here

    return bucketIteratorFactory.iteratorInDirectory(new File(coldPath),
        indexName);
  }

  private Index getSplunkIndexByName(String indexName) {
    Index splunkIndex = splunkService.getIndexes().get(indexName);
    if (splunkIndex == null)
      throw new IllegalIndexException(indexName);
    else
      return splunkIndex;
  }
View Full Code Here

    return indexes;
  }

  public void getIndexPaths_indexWithColdPath_mapWithColdPathToIndexName() {
    Map<String, Index> indexes = stubIndexesMap();
    Index index = mock(Index.class);
    String indexName = setupIndexInIndexes(indexes, index);
    File coldDbPath = createFilePath();
    when(index.getColdPathExpanded()).thenReturn(coldDbPath.getAbsolutePath());

    assertPathIsMappedToIndexName(coldDbPath, indexName);
  }
View Full Code Here

    assertEquals(paths, expected);
  }

  public void getIndexPaths_indexWithHomePath_mapWithHomePathToIndexName() {
    Map<String, Index> indexes = stubIndexesMap();
    Index index = mock(Index.class);
    String indexName = setupIndexInIndexes(indexes, index);
    File homeDbPath = createFilePath();
    when(index.getHomePathExpanded()).thenReturn(homeDbPath.getAbsolutePath());

    assertPathIsMappedToIndexName(homeDbPath, indexName);
  }
View Full Code Here

TOP

Related Classes of com.splunk.Index

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.