use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project hazelcast by hazelcast.
the class AbstractXmlConfigHelper method fillNativeMemoryConfig.
@SuppressFBWarnings("DM_BOXED_PRIMITIVE_FOR_PARSING")
protected void fillNativeMemoryConfig(Node node, NativeMemoryConfig nativeMemoryConfig) {
final NamedNodeMap atts = node.getAttributes();
final Node enabledNode = atts.getNamedItem("enabled");
final boolean enabled = enabledNode != null && getBooleanValue(getTextContent(enabledNode).trim());
nativeMemoryConfig.setEnabled(enabled);
final Node allocTypeNode = atts.getNamedItem("allocator-type");
final String allocType = getTextContent(allocTypeNode);
if (allocType != null && !"".equals(allocType)) {
nativeMemoryConfig.setAllocatorType(NativeMemoryConfig.MemoryAllocatorType.valueOf(upperCaseInternal(allocType)));
}
for (Node n : childElements(node)) {
final String nodeName = cleanNodeName(n);
if ("size".equals(nodeName)) {
final NamedNodeMap attrs = n.getAttributes();
final String value = getTextContent(attrs.getNamedItem("value"));
final MemoryUnit unit = MemoryUnit.valueOf(getTextContent(attrs.getNamedItem("unit")));
MemorySize memorySize = new MemorySize(Long.valueOf(value), unit);
nativeMemoryConfig.setSize(memorySize);
} else if ("min-block-size".equals(nodeName)) {
String value = getTextContent(n);
nativeMemoryConfig.setMinBlockSize(Integer.parseInt(value));
} else if ("page-size".equals(nodeName)) {
String value = getTextContent(n);
nativeMemoryConfig.setPageSize(Integer.parseInt(value));
} else if ("metadata-space-percentage".equals(nodeName)) {
String value = getTextContent(n);
try {
Number percentage = new DecimalFormat("##.#").parse(value);
nativeMemoryConfig.setMetadataSpacePercentage(percentage.floatValue());
} catch (ParseException e) {
LOGGER.info("Metadata space percentage, [" + value + "], is not a proper value. Default value will be used!");
}
}
}
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project hazelcast by hazelcast.
the class MapProxySupport method putAllInternal.
/**
* This method will group all puts per partition and send a
* {@link com.hazelcast.map.impl.operation.PutAllPartitionAwareOperationFactory} per member.
* <p/>
* If there are e.g. five keys for a single member, there will only be a single remote invocation
* instead of having five remote invocations.
* <p/>
* There is also an optional support for batching to send smaller packages.
* Takes care about {@code null} checks for keys and values.
*/
@SuppressWarnings({ "checkstyle:npathcomplexity", "UnnecessaryBoxing" })
@SuppressFBWarnings(value = "DM_NUMBER_CTOR", justification = "we need a shared counter object for each member per partition")
protected void putAllInternal(Map<?, ?> map) {
try {
int mapSize = map.size();
if (mapSize == 0) {
return;
}
boolean useBatching = isPutAllUseBatching(mapSize);
int partitionCount = partitionService.getPartitionCount();
int initialSize = getPutAllInitialSize(useBatching, mapSize, partitionCount);
Map<Address, List<Integer>> memberPartitionsMap = partitionService.getMemberPartitionsMap();
// init counters for batching
MutableLong[] counterPerMember = null;
Address[] addresses = null;
if (useBatching) {
counterPerMember = new MutableLong[partitionCount];
addresses = new Address[partitionCount];
for (Entry<Address, List<Integer>> addressListEntry : memberPartitionsMap.entrySet()) {
MutableLong counter = new MutableLong();
Address address = addressListEntry.getKey();
for (int partitionId : addressListEntry.getValue()) {
counterPerMember[partitionId] = counter;
addresses[partitionId] = address;
}
}
}
// fill entriesPerPartition
MapEntries[] entriesPerPartition = new MapEntries[partitionCount];
for (Entry entry : map.entrySet()) {
checkNotNull(entry.getKey(), NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(entry.getValue(), NULL_VALUE_IS_NOT_ALLOWED);
Data keyData = toData(entry.getKey(), partitionStrategy);
int partitionId = partitionService.getPartitionId(keyData);
MapEntries entries = entriesPerPartition[partitionId];
if (entries == null) {
entries = new MapEntries(initialSize);
entriesPerPartition[partitionId] = entries;
}
entries.add(keyData, toData(entry.getValue()));
if (useBatching) {
long currentSize = ++counterPerMember[partitionId].value;
if (currentSize % putAllBatchSize == 0) {
List<Integer> partitions = memberPartitionsMap.get(addresses[partitionId]);
invokePutAllOperation(addresses[partitionId], partitions, entriesPerPartition);
}
}
}
// invoke operations for entriesPerPartition
for (Entry<Address, List<Integer>> entry : memberPartitionsMap.entrySet()) {
invokePutAllOperation(entry.getKey(), entry.getValue(), entriesPerPartition);
}
} catch (Exception e) {
throw rethrow(e);
}
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project hazelcast by hazelcast.
the class ClientCacheProxyFactory method findCacheConfig.
@SuppressFBWarnings("RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED")
private CacheConfig findCacheConfig(String cacheName) {
CacheConfig cacheConfig = configs.get(cacheName);
if (cacheConfig != null) {
return cacheConfig;
}
// otherwise, request it from server
String simpleCacheName = cacheName.substring(HazelcastCacheManager.CACHE_MANAGER_PREFIX.length());
cacheConfig = ClientCacheHelper.getCacheConfig(client, cacheName, simpleCacheName);
if (cacheConfig != null) {
configs.putIfAbsent(cacheName, cacheConfig);
}
return cacheConfig;
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project hazelcast by hazelcast.
the class ClientConsoleApp method handleAt.
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
private void handleAt(String first) {
if (first.length() == 1) {
println("usage: @<file-name>");
return;
}
File f = new File(first.substring(1));
println("Executing script file " + f.getAbsolutePath());
if (f.exists()) {
try {
BufferedReader br = new BufferedReader(new FileReader(f));
String l = br.readLine();
while (l != null) {
handleCommand(l);
l = br.readLine();
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
} else {
println("File not found! " + f.getAbsolutePath());
}
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project hazelcast by hazelcast.
the class HazelcastManifestTransformer method precompileOverrideInstructions.
@SuppressFBWarnings(value = "NP_UNWRITTEN_FIELD", justification = "Field is set by Maven")
private void precompileOverrideInstructions() {
String importPackageInstructions = overrideInstructions.get(IMPORT_PACKAGE);
if (importPackageInstructions != null) {
List<String> packageInstructions = ElementParser.parseDelimitedString(importPackageInstructions, ',', true);
for (String packageInstruction : packageInstructions) {
PackageDefinition packageDefinition = new PackageDefinition(packageInstruction);
Instruction instruction = Instruction.getPattern(packageDefinition.packageName);
System.out.println("Compiled import instruction '" + packageInstruction + "' -> " + instruction);
importOverrideInstructions.add(new InstructionDefinition(packageDefinition, instruction));
}
}
String exportPackageInstructions = overrideInstructions.get(EXPORT_PACKAGE);
if (exportPackageInstructions != null) {
List<String> packageInstructions = ElementParser.parseDelimitedString(exportPackageInstructions, ',', true);
for (String packageInstruction : packageInstructions) {
PackageDefinition packageDefinition = new PackageDefinition(packageInstruction);
Instruction instruction = Instruction.getPattern(packageDefinition.packageName);
System.out.println("Compiled export instruction '" + packageInstruction + "' -> " + instruction);
exportOverrideInstructions.add(new InstructionDefinition(packageDefinition, instruction));
}
}
}
Aggregations