Skip to content

Commit 03b7c77

Browse files
committed
Code liniting
1 parent 443fd1c commit 03b7c77

4 files changed

Lines changed: 43 additions & 39 deletions

File tree

src/main/java/picoded/dstack/mongodb/MongoDBStack.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public static String getFullConnectionURL(GenericConvertMap<String, Object> conf
5959
int port = config.getInt("port", 27017);
6060
String opts = config.getString("opt_str", "w=majority&retryWrites=true&retryReads=true"
6161
+ "&maxPoolSize=10&compressors=zstd");
62-
// "&readPreference=master&readConcernLevel=majority"
63-
// "&readPreference=nearest&readConcernLevel=linearizable"
62+
// "&readPreference=master&readConcernLevel=majority"
63+
// "&readPreference=nearest&readConcernLevel=linearizable"
6464

6565
// Lets do a logging, for missing read concern if its not configured
6666
if (opts.indexOf("readConcernLevel") < 0) {
@@ -75,10 +75,10 @@ public static String getFullConnectionURL(GenericConvertMap<String, Object> conf
7575
// Unless you know what your doing from a performance standpoint, it is strongly recommended to use
7676
// `readConcernLevel=linearizable`
7777
//
78-
LOGGER.warning("MongoDB is configured without readConcernLevel, "+
79-
"this is alright for a single node, but `readConcernLevel=linearizable`"+
80-
"or `readPreference=master&readConcernLevel=majority`"+
81-
"is highly recommended for replica clusters to ensure read after write consistency.");
78+
LOGGER.warning("MongoDB is configured without readConcernLevel, "
79+
+ "this is alright for a single node, but `readConcernLevel=linearizable`"
80+
+ "or `readPreference=master&readConcernLevel=majority`"
81+
+ "is highly recommended for replica clusters to ensure read after write consistency.");
8282
}
8383

8484
// In the future we may want to support opt_map

src/main/java/picoded/dstack/struct/cache/StructCacheUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class StructCacheUtil {
1414
* Utility function used to build a new Cache2k cache instance
1515
* This handles all the various common config settings, and set it up accordingly
1616
*/
17-
static <V> Cache<String, V> setupCache2kMap(Cache2kBuilder<String,V> builder, String name, GenericConvertMap<String, Object> config) {
17+
static <V> Cache<String, V> setupCache2kMap(Cache2kBuilder<String, V> builder, String name,
18+
GenericConvertMap<String, Object> config) {
1819

1920
//
2021
// Get Config

src/main/java/picoded/dstack/struct/cache/StructCache_DataObjectMap.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ public void systemSetup() {
148148
}
149149

150150
// Build the cache
151-
_valueMap = StructCacheUtil.setupCache2kMap(new Cache2kBuilder<String, Map<String,Object>>(){}, cacheName(), configMap());
151+
_valueMap = StructCacheUtil.setupCache2kMap(
152+
new Cache2kBuilder<String, Map<String, Object>>() {
153+
}, cacheName(), configMap());
152154

153155
// Add it back to the global cache
154156
globalCacheMap.put(cacheName(), _valueMap);

src/main/java/picoded/dstack/struct/cache/StructCache_KeyValueMap.java

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Built ontop of the StructCache_KeyValueMap implementation.
2323
**/
2424
public class StructCache_KeyValueMap extends Core_KeyValueMap {
25-
25+
2626
//--------------------------------------------------------------------------
2727
//
2828
// Constructor
@@ -59,14 +59,14 @@ static public class CacheValue implements Serializable {
5959
public String value;
6060
public long expire;
6161
}
62-
62+
6363
static CacheValue cacheValueBuilder(String val, long exp) {
6464
CacheValue ret = new CacheValue();
6565
ret.value = val;
6666
ret.expire = exp;
6767
return ret;
6868
}
69-
69+
7070
/**
7171
* Global static cache map,
7272
* Used to persist all the various cache maps used.
@@ -158,32 +158,33 @@ public void systemSetup() {
158158
}
159159

160160
// Build the cache
161-
Cache2kBuilder<String, CacheValue> builder = new Cache2kBuilder<String, CacheValue>(){};
161+
Cache2kBuilder<String, CacheValue> builder = new Cache2kBuilder<String, CacheValue>() {
162+
};
162163
builder.storeByReference(true);
163164
_valueMap = StructCacheUtil.setupCache2kMap(builder, cacheName(), configMap());
164165

165166
// Add it back to the global cache
166167
globalCacheMap.put(cacheName(), _valueMap);
167168
}
168-
169+
169170
}
170-
171+
171172
@Override
172173
public void systemDestroy() {
173174
synchronized (StructCache_KeyValueMap.class) {
174175
_valueMap.clear();
175176
globalCacheMap.remove(cacheName());
176177
_valueMap = null;
177178
}
178-
179+
179180
}
180-
181+
181182
@Override
182183
public void maintenance() {
183184
// Does nothing
184-
185+
185186
}
186-
187+
187188
//--------------------------------------------------------------------------
188189
//
189190
// Set and get values
@@ -203,21 +204,21 @@ public void maintenance() {
203204
@Override
204205
public String setValueRaw(String key, String value, long expire) {
205206
// Handles null removal
206-
if( value == null ) {
207+
if (value == null) {
207208
valueMap().remove(key);
208209
return null;
209210
}
210-
211+
211212
// Store and configure expiry
212213
valueMap().put(key, cacheValueBuilder(value, expire));
213-
if( expire > 0 ) {
214+
if (expire > 0) {
214215
// Note that cache expiry config, may take priority
215216
// so this should not be relied on in itself
216217
valueMap().expireAt(key, expire);
217218
}
218219
return null;
219220
}
220-
221+
221222
/**
222223
* [Internal use, to be extended in future implementation]
223224
* Sets the expire time stamp value, raw without validation
@@ -230,22 +231,22 @@ public String setValueRaw(String key, String value, long expire) {
230231
@Override
231232
public void setExpiryRaw(String key, long time) {
232233
CacheValue cv = valueMap().get(key);
233-
if( cv == null ) {
234+
if (cv == null) {
234235
// Does nothing if cv == null
235236
return;
236237
}
237-
238+
238239
// Set the actual expire value
239240
cv.expire = time;
240-
241+
241242
// Configure cache2k expire values
242-
if( time > 0 ) {
243+
if (time > 0) {
243244
// Note that cache expiry config, may take priority
244245
// so this should not be relied on in itself
245246
valueMap().expireAt(key, time);
246247
}
247248
}
248-
249+
249250
/**
250251
* [Internal use, to be extended in future implementation]
251252
*
@@ -259,15 +260,15 @@ public void setExpiryRaw(String key, long time) {
259260
@Override
260261
public MutablePair<String, Long> getValueExpiryRaw(String key, long now) {
261262
CacheValue cv = valueMap().get(key);
262-
if( cv == null ) {
263+
if (cv == null) {
263264
// Does nothing if cv == null
264265
return null;
265266
}
266-
if( cv.expire > 0 && cv.expire <= System.currentTimeMillis() ) {
267+
if (cv.expire > 0 && cv.expire <= System.currentTimeMillis()) {
267268
// Value should be expired, does nothing
268269
return null;
269270
}
270-
return new MutablePair<String,Long>(cv.value, cv.expire);
271+
return new MutablePair<String, Long>(cv.value, cv.expire);
271272
}
272273

273274
//--------------------------------------------------------------------------
@@ -279,33 +280,33 @@ public MutablePair<String, Long> getValueExpiryRaw(String key, long now) {
279280
@Override
280281
public Set<String> keySet(String value) {
281282
// Optimized for all
282-
if( value == null ) {
283+
if (value == null) {
283284
return valueMap().asMap().keySet();
284285
}
285-
286+
286287
// We have to do a search
287288
Set<String> full = valueMap().asMap().keySet();
288289
Set<String> ret = new HashSet<>();
289290
long now = System.currentTimeMillis();
290-
291+
291292
// Lets iterate each key
292-
for(String key : full) {
293+
for (String key : full) {
293294
CacheValue cv = valueMap().get(key);
294-
if( cv == null ) {
295+
if (cv == null) {
295296
// Does nothing if cv == null
296297
continue;
297298
}
298-
if( cv.expire > 0 && cv.expire <= now ) {
299+
if (cv.expire > 0 && cv.expire <= now) {
299300
// Value should be expired, does nothing
300301
continue;
301302
}
302-
if( cv.value == value ) {
303+
if (cv.value == value) {
303304
ret.add(key);
304305
}
305306
}
306-
307+
307308
// Return the filtered set
308309
return ret;
309310
}
310-
311+
311312
}

0 commit comments

Comments
 (0)