All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dynatrace.openkit.core.caching.BeaconCache Maven / Gradle / Ivy

There is a newer version: 3.3.0
Show newest version
/**
 * Copyright 2018-2019 Dynatrace LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.dynatrace.openkit.core.caching;

import java.util.Observer;
import java.util.Set;

/**
 * Beacon Cache used to cache the Beacons generated by all sessions, actions, ...
 */
public interface BeaconCache {

    /**
     * Add an {@link Observer} which gets notified after a new event data or action data got inserted.
     *
     * @param o Observer to add.
     */
    void addObserver(Observer o);

    /**
     * Add event data for a given {@code beaconID} to this cache.
     *
     * 

* All registered observers are notified, after the event data has been added. *

* * @param beaconID The beacon's ID (aka Session ID) for which to add event data. * @param timestamp The data's timestamp. * @param data serialized event data to add. */ void addEventData(Integer beaconID, long timestamp, String data); /** * Add action data for a given {@code beaconID} to this cache. * * @param beaconID The beacon's ID (aka Session ID) for which to add action data. * @param timestamp The data's timestamp. * @param data serialized action data to add. */ void addActionData(Integer beaconID, long timestamp, String data); /** * Delete a cache entry for a given {@code beaconID}. * * @param beaconID The beacon's ID (aka Session ID) which to delete. */ void deleteCacheEntry(Integer beaconID); /** * Get the next chunk for sending to the backend. * *

* Note: This method must only be invoked from the beacon sending thread. *

* * @param beaconID The beacon id for which to get the next chunk. * @param chunkPrefix Prefix to append to the beginning of the chunk. * @param maxSize Maximum chunk size. As soon as chunk's size is greater than or equal to maxSize result is returned. * @param delimiter Delimiter between consecutive chunks. * * @return {@code null} if given {@code beaconID} does not exist, an empty string, if there is no more data to send * or the next chunk to send. */ String getNextBeaconChunk(Integer beaconID, String chunkPrefix, int maxSize, char delimiter); /** * Remove all data that was previously included in chunks. * *

* This method must be called, when data retrieved via {@link #getNextBeaconChunk(Integer, String, int, char)} * was successfully sent to the backend, otherwise subsequent calls to {@link #getNextBeaconChunk(Integer, String, int, char)} * will retrieve the same data again and again. *

* *

* Note: This method must only be invoked from the beacon sending thread. *

* * @param beaconID The beacon id for which to remove already chunked data. */ void removeChunkedData(Integer beaconID); /** * Reset all data that was previously included in chunks. * *

* Note: This method must only be invoked from the beacon sending thread. *

* * @param beaconID The beacon id for which to remove already chunked data. */ void resetChunkedData(Integer beaconID); /** * Get a Set of currently inserted Beacon ids. * *

* The return value is a snapshot of currently inserted beacon ids. * All changes made after this call are not reflected in the returned Set. *

* * @return Snapshot of all beacon ids in the cache. */ Set getBeaconIDs(); /** * Evict {@link BeaconCacheRecord beacon cache records} by age for a given beacon. * * @param beaconID The beacon's identifier. * @param minTimestamp The minimum timestamp allowed. * * @return Returns the number of evicted cache records. */ int evictRecordsByAge(Integer beaconID, long minTimestamp); /** * Evict {@link BeaconCacheRecord beacon cache records} by number for given beacon. * * @param beaconID The beacon's identifier. * @param numRecords The maximum number of records to evict. * * @return Returns the number of evicted cache records. */ int evictRecordsByNumber(Integer beaconID, int numRecords); /** * Get number of bytes currently stored in cache. * * @return Number of bytes currently stored in cache. */ long getNumBytesInCache(); /** * Tests if an cached entry for {@code beaconID} is empty. * * @param beaconID beaconID The beacon's identifier. * @return {@code true} if the cached entry is empty, {@code false} otherwise. */ boolean isEmpty(Integer beaconID); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy