Skip to content

Commit

Permalink
Merge pull request #111 from flipkart-incubator/cleanup/accessMethods
Browse files Browse the repository at this point in the history
Changes to remove access methods generated by compiler
  • Loading branch information
anirudhramanan authored Nov 26, 2016
2 parents e9839cc + 7c4a854 commit 80d0ce4
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 57 deletions.
28 changes: 14 additions & 14 deletions batching/src/main/java/com/flipkart/batching/BatchManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
*/

public class BatchManager<E extends Data, T extends Batch<E>> implements BatchController<E, T> {
private Handler handler;
private BatchingStrategy<E, T> batchingStrategy;
private SerializationStrategy<E, T> serializationStrategy;
Handler handler;
BatchingStrategy<E, T> batchingStrategy;
SerializationStrategy<E, T> serializationStrategy;
private Logger logger = LoggerFactory.getLogger(BatchManager.class);

protected BatchManager(Builder builder, final Context context) {
Expand Down Expand Up @@ -125,13 +125,13 @@ public void run() {
});
}

private void logEvents(Collection<E> dataCollection) {
void logEvents(Collection<E> dataCollection) {
if (logger.isDebugEnabled()) {
logger.debug("Data added {}", dataCollection);
}
}

private void assignEventIds(Collection<E> dataCollection) {
void assignEventIds(Collection<E> dataCollection) {
int i = 0;
for (E data : dataCollection) {
i++;
Expand Down Expand Up @@ -170,18 +170,18 @@ public void run() {
* @param handler instance of {@link Handler}
*/

private void initialize(BatchController<E, T> batchController, Context context,
OnBatchReadyListener<E, T> onBatchReadyListener, Handler handler) {
void initialize(BatchController<E, T> batchController, Context context,
OnBatchReadyListener<E, T> onBatchReadyListener, Handler handler) {
batchingStrategy.onInitialized(context, onBatchReadyListener, handler);
}

public static class Builder<E extends Data, T extends Batch<E>> {
static class Builder<E extends Data, T extends Batch<E>> {
Set<Class<E>> dataTypes = new HashSet<>();
Set<Class<T>> batchInfoTypes = new HashSet<>();
private Handler handler;
private BatchingStrategy batchingStrategy;
private OnBatchReadyListener onBatchReadyListener;
private SerializationStrategy serializationStrategy;
private Set<Class<E>> dataTypes = new HashSet<>();
private Set<Class<T>> batchInfoTypes = new HashSet<>();

public SerializationStrategy getSerializationStrategy() {
return serializationStrategy;
Expand Down Expand Up @@ -209,11 +209,11 @@ public Builder setOnBatchReadyListener(OnBatchReadyListener onBatchReadyListener
return this;
}

public BatchingStrategy getBatchingStrategy() {
BatchingStrategy getBatchingStrategy() {
return batchingStrategy;
}

public Builder setBatchingStrategy(BatchingStrategy batchingStrategy) {
Builder setBatchingStrategy(BatchingStrategy batchingStrategy) {
if (batchingStrategy != null) {
this.batchingStrategy = batchingStrategy;
} else {
Expand All @@ -231,12 +231,12 @@ public Builder setHandler(Handler handler) {
return this;
}

public Builder registerDataType(Class<E> subClass) {
Builder registerDataType(Class<E> subClass) {
dataTypes.add(subClass);
return this;
}

public Builder registerBatchInfoType(Class<T> subClass) {
Builder registerBatchInfoType(Class<T> subClass) {
batchInfoTypes.add(subClass);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
*/

public class TagBatchManager<E extends Data, T extends Batch<E>> implements BatchController<E, T> {
private Handler handler;
private SerializationStrategy<E, T> serializationStrategy;
private TagBatchingStrategy<TagData> tagBatchingStrategy;
private TagBatchReadyListener<TagData> tagBatchReadyListener;
Handler handler;
SerializationStrategy<E, T> serializationStrategy;
TagBatchingStrategy<TagData> tagBatchingStrategy;
TagBatchReadyListener<TagData> tagBatchReadyListener;
private ArrayList<TagInfo> tagParametersList = new ArrayList<>();

protected TagBatchManager(Builder builder, final Context context) {
Expand Down Expand Up @@ -99,7 +99,7 @@ public static void registerBuiltInTypes(SerializationStrategy serializationStrat
serializationStrategy.registerBatch(SizeTimeBatchingStrategy.SizeTimeBatch.class);
}

private void initialize(TagBatchManager<E, T> tagBatchManager, Context context, OnBatchReadyListener onBatchReadyListener, Handler handler) {
void initialize(TagBatchManager<E, T> tagBatchManager, Context context, OnBatchReadyListener onBatchReadyListener, Handler handler) {
tagBatchingStrategy.onInitialized(context, onBatchReadyListener, handler);
}

Expand Down Expand Up @@ -128,7 +128,7 @@ public void run() {
});
}

private void assignEventIds(Collection<E> dataCollection) {
void assignEventIds(Collection<E> dataCollection) {
int i = 0;
for (E data : dataCollection) {
i++;
Expand Down Expand Up @@ -158,10 +158,10 @@ public void run() {
}

public static class Builder<E extends Data, T extends Batch<E>> {
Set<Class<E>> dataTypes = new HashSet<>();
Set<Class<T>> batchInfoTypes = new HashSet<>();
private Handler handler;
private SerializationStrategy serializationStrategy;
private Set<Class<E>> dataTypes = new HashSet<>();
private Set<Class<T>> batchInfoTypes = new HashSet<>();
private ArrayList<TagInfo> tagInfoList = new ArrayList<>();

public ArrayList<TagInfo> getTagInfoList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@
* Network Persisted Batch Ready Listener
*/
public class NetworkPersistedBatchReadyListener<E extends Data, T extends Batch<E>> extends TrimPersistedBatchReadyListener<E, T> {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(NetworkPersistedBatchReadyListener.class);
static final org.slf4j.Logger log = LoggerFactory.getLogger(NetworkPersistedBatchReadyListener.class);
private static final int HTTP_SERVER_ERROR_CODE_RANGE_START = 500;
private static final int HTTP_SERVER_ERROR_CODE_RANGE_END = 599;
public int defaultTimeoutMs = 2500;
public float defaultBackoffMultiplier = 1f;
T lastBatch;
int retryCount = 0;
int mCurrentTimeoutMs = 0;
int maxRetryCount;
boolean needsResumeOnReady = false;
boolean waitingForCallback = false;
boolean receiverRegistered;
boolean callFinishAfterMaxRetry = false;
private NetworkBatchListener<E, T> networkBatchListener;
private Context context;
private T lastBatch;
private int retryCount = 0;
private int mCurrentTimeoutMs = 0;
private int maxRetryCount;
private NetworkBroadcastReceiver networkBroadcastReceiver = new NetworkBroadcastReceiver();
private boolean needsResumeOnReady = false;
private boolean waitingForCallback = false;
private boolean receiverRegistered;
private boolean callFinishAfterMaxRetry = false;
private PersistedBatchCallback<T> persistedBatchCallback = new PersistedBatchCallback<T>() {
@Override
public void onPersistFailure(T batch, Exception e) {
Expand All @@ -81,6 +81,7 @@ public void onFinish() {
unregisterReceiver();
}
};

public NetworkPersistedBatchReadyListener(final Context context, String filePath,
SerializationStrategy<E, T> serializationStrategy,
final Handler handler, NetworkBatchListener<E, T> listener,
Expand Down Expand Up @@ -120,7 +121,7 @@ public void setDefaultBackoffMultiplier(float defaultBackoffMultiplier) {
this.defaultBackoffMultiplier = defaultBackoffMultiplier;
}

private void unregisterReceiver() {
void unregisterReceiver() {
if (receiverRegistered) {
context.unregisterReceiver(networkBroadcastReceiver);
receiverRegistered = false;
Expand All @@ -130,7 +131,7 @@ private void unregisterReceiver() {
}
}

private void registerReceiverIfRequired() {
void registerReceiverIfRequired() {
if (!receiverRegistered) {
//Register the broadcast receiver
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
Expand All @@ -152,11 +153,11 @@ public void onReady(BatchingStrategy<E, T> causingStrategy, T batch) {
}


private boolean isConnectedToNetwork() {
boolean isConnectedToNetwork() {
return networkBatchListener.isNetworkConnected(context);
}

private void makeNetworkRequest(final T batch, boolean isRetry) {
void makeNetworkRequest(final T batch, boolean isRetry) {
if (isConnectedToNetwork()) {
if (log.isDebugEnabled()) {
log.debug("Performing network request for batch : {}, listener {}", batch, this);
Expand Down Expand Up @@ -230,7 +231,7 @@ private void resetRetryCounters() {
*
* @return new timeOut
*/
private int exponentialBackOff() {
int exponentialBackOff() {
int timeOut = mCurrentTimeoutMs;
mCurrentTimeoutMs += (mCurrentTimeoutMs * defaultBackoffMultiplier);
return timeOut;
Expand All @@ -243,7 +244,7 @@ public void finish(T batch) {
super.finish(batch);
}

private void resume() {
void resume() {
handler.post(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
*/
public class PersistedBatchReadyListener<E extends Data, T extends Batch<E>> implements OnBatchReadyListener<E, T>, LenientQueueFile.QueueFileErrorCallback {
private static final int MAX_ITEMS_CACHED = 2000;
private static final org.slf4j.Logger log = LoggerFactory.getLogger(PersistedBatchReadyListener.class);
protected final Handler handler;
protected final String filePath;
private final Queue<T> cachedQueue;
private PersistedBatchCallback<T> listener;
private ObjectQueue<T> queueFile;
private BatchObjectConverter<E, T> converter;
private boolean isWaitingToFinish;
private T peekedBatch;
static final org.slf4j.Logger log = LoggerFactory.getLogger(PersistedBatchReadyListener.class);
final Handler handler;
final String filePath;
final Queue<T> cachedQueue;
PersistedBatchCallback<T> listener;
ObjectQueue<T> queueFile;
BatchObjectConverter<E, T> converter;
boolean isWaitingToFinish;
T peekedBatch;


public PersistedBatchReadyListener(String filePath, SerializationStrategy<E, T> serializationStrategy, Handler handler, @Nullable PersistedBatchCallback<T> listener) {
Expand Down Expand Up @@ -138,7 +138,7 @@ protected boolean remove(int num) {
return result;
}

private void callPersistFailure(T batch, Exception e) {
void callPersistFailure(T batch, Exception e) {
if (listener != null) {
listener.onPersistFailure(batch, e);
}
Expand All @@ -151,7 +151,7 @@ private void callPersistSuccess(T batch) {

}

private void initializeIfRequired() {
void initializeIfRequired() {
if (!isInitialized()) {
tryCreatingQueueFile();
onInitialized();
Expand Down Expand Up @@ -231,7 +231,7 @@ public void run() {
});
}

private void checkPendingAndContinue() {
void checkPendingAndContinue() {
initializeIfRequired();
if (queueFile.size() > 0) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class TrimPersistedBatchReadyListener<E extends Data, T extends Batch<E>>
protected final Handler handler;
private final TrimmedBatchCallback trimListener;
private int trimSize, maxQueueSize;
private int mode;
int mode;

public TrimPersistedBatchReadyListener(String filePath, SerializationStrategy<E, T> serializationStrategy, Handler handler, int maxQueueSize, int trimSize, int mode, PersistedBatchCallback<T> persistedBatchCallback, TrimmedBatchCallback trimmedBatchCallback) {
super(filePath, serializationStrategy, handler, persistedBatchCallback);
Expand Down Expand Up @@ -80,7 +80,7 @@ public void run() {
});
}

private void trimQueue() {
void trimQueue() {
int oldSize = getSize();
if (oldSize >= maxQueueSize && remove(trimSize)) {
callTrimListener(oldSize, getSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class FileObjectQueue<T> implements ObjectQueue<T> {
* Keep file around for error reporting.
*/
private final File file;
private final Converter<T> converter;
final Converter<T> converter;
private Listener<T> listener;

public FileObjectQueue(File file, QueueFile queueFile, Converter<T> converter) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private Element readElement(int position) throws IOException {
/**
* Wraps the position if it exceeds the end of the file.
*/
private int wrapPosition(int position) {
int wrapPosition(int position) {
return position < fileLength ? position
: HEADER_LENGTH + position - fileLength;
}
Expand Down Expand Up @@ -263,7 +263,7 @@ private void ringErase(int position, int length) throws IOException {
* @param buffer to read into
* @param count # of bytes to read
*/
private void ringRead(int position, byte[] buffer, int offset, int count) throws IOException {
void ringRead(int position, byte[] buffer, int offset, int count) throws IOException {
position = wrapPosition(position);
if (position + count <= fileLength) {
raf.seek(position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@
* }</pre>
*/
public final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory {
private final Class<?> baseType;
private final String typeFieldName;
final Class<?> baseType;
final String typeFieldName;
private final Map<String, Class<?>> labelToSubtype = new LinkedHashMap<String, Class<?>>();
private final Map<Class<?>, String> subtypeToLabel = new LinkedHashMap<Class<?>, String>();
final Map<Class<?>, String> subtypeToLabel = new LinkedHashMap<Class<?>, String>();

private RuntimeTypeAdapterFactory(Class<?> baseType, String typeFieldName) {
if (typeFieldName == null || baseType == null) {
Expand Down

0 comments on commit 80d0ce4

Please sign in to comment.