id stringlengths 7 14 | text stringlengths 1 106k |
|---|---|
152134_47 | public void parse (Reader input, Writer output) throws Exception {
this.input = input;
this.output = output;
int i;
while (-1 != (i = input.read())) {
this.c = (char)i;
this.cnt++;
switch (this.state) {
case IN_BODY:
this.handleInBody();
break;
default:
this.handleUnknown();
break;
}
}
} |
152134_48 | public void parse (Reader input, Writer output) throws Exception {
this.input = input;
this.output = output;
int i;
while (-1 != (i = input.read())) {
this.c = (char)i;
this.cnt++;
switch (this.state) {
case IN_BODY:
this.handleInBody();
break;
default:
this.handleUnknown();
break;
}
}
} |
152134_49 | public void parse(Reader input, Writer output) throws Exception {
this.input = input;
this.output = output;
int c;
while (-1 != (c = input.read())) {
output.write(c);
}
} |
1526495_0 | public void prepareESBDeployment() throws BusNotPreparedException {
PreparerTask task = new PreparerTask();
InvokerFactory<Void> factory = new InvokerFactory<Void>();
Invoker<Void> invoker = factory.geNewInvokerInstance(TASK_NAME, task);
try {
invoker.invoke();
} catch (InvokerException e) {
throw new BusNotPreparedException();
}
} |
1526495_1 | public void prepareESBDeployment() throws BusNotPreparedException {
PreparerTask task = new PreparerTask();
InvokerFactory<Void> factory = new InvokerFactory<Void>();
Invoker<Void> invoker = factory.geNewInvokerInstance(TASK_NAME, task);
try {
invoker.invoke();
} catch (InvokerException e) {
throw new BusNotPreparedException();
}
} |
1526495_2 | @Override
public String proxifyService(String serviceUrl, String serviceWsdl) throws EasyESBException {
rManagementClient cli = linagoraFactory.getUserManagementClient(adminEndpoint);
ing response = null;
{
response = cli.proxify(serviceUrl, serviceWsdl);
atch (ManagementException e) {
fail("Proxifying " + serviceUrl + " in the bus " + adminEndpoint + " failed.");
ing proxifiedUri = fixIP(response, nodeIp);
urn proxifiedUri;
} |
1526495_3 | public void configureTopology() throws TopologyNotConfigureException {
for (DeployableService service : chor.getDeployableServices()) {
for (ServiceInstance instance : service.getInstances()) {
EasyESBNode esbNode = getESBNode(instance);
List<ServiceDependency> dependencies = service.getSpec().getDependencies();
if (dependencies != null) {
for (ServiceDependency dependency : dependencies) {
DeployableService providingService = chor.getDeployableServiceBySpecName(dependency
.getServiceSpecName());
for (ServiceInstance providingInstance : providingService.getInstances()) {
EasyESBNode neighbourEsbNode = getESBNode(providingInstance);
try {
esbNode.addNeighbour(neighbourEsbNode);
neighbourEsbNode.addNeighbour(esbNode);
} catch (EasyESBException e) {
throw new TopologyNotConfigureException();
}
}
}
}
}
}
} |
1526495_4 | public void prepareDeployment() throws PrepareDeploymentFailedException {
DeploymentPrepare();
eduleHandler();
} |
1526495_5 | public DeployableService createService(DeployableServiceSpec serviceSpec) throws ServiceNotCreatedException {
{
service = new DeployableService(serviceSpec);
service.generateUUID();
atch (IllegalArgumentException e1) {
logger.error("Could not create service " + serviceSpec.getName());
throw new ServiceNotCreatedException(serviceSpec.getName());
<CloudNode> selectedNodes = prepareDeployment();
vice.setSelectedNodes(selectedNodes);
ger.info("Created service " + service);
urn service;
} |
1526495_6 | @Override
public void applyUpdate() throws UpdateActionFailedException {
decreaseAmount = currentService.getSpec().getNumberOfInstances() - newSpec.getNumberOfInstances();
viceUndeploymentPreparer undeploymentPreparer = ServiceUndeploymentPreparerFactory.getNewInstance(
rrentService, decreaseAmount);
{
undeploymentPreparer.prepareUndeployment();
currentService.setSpec(newSpec);
atch (Exception e) {
throw new UpdateActionFailedException();
} |
1526495_7 | public List<UpdateAction> getActions(DeployableService currentService, DeployableServiceSpec newServiceSpec) {
DeployableServiceSpec currentServiceSpec = currentService.getSpec();
List<UpdateAction> actions = new ArrayList<UpdateAction>();
logger.info("Calculating changes on service spec \nOld = " + currentServiceSpec + "\nNew = " + newServiceSpec);
if (currentServiceSpec.getNumberOfInstances() < newServiceSpec.getNumberOfInstances()) {
UpdateAction action = new IncreaseNumberOfReplicas(currentService, newServiceSpec);
actions.add(action);
} else if (currentServiceSpec.getNumberOfInstances() > newServiceSpec.getNumberOfInstances()) {
UpdateAction action = new DecreaseNumberOfReplicas(currentService, newServiceSpec);
actions.add(action);
}
if (!(currentServiceSpec.getResourceImpact() == null || currentServiceSpec.getResourceImpact().getMemory() == null)) {
if (!(currentServiceSpec.getResourceImpact().getMemory().ordinal() == newServiceSpec.getResourceImpact()
.getMemory().ordinal())) {
UpdateAction action = new Migrate(currentService, newServiceSpec);
actions.add(action);
}
}
logger.info("Detected changes: " + actions);
return actions;
} |
1526495_8 | public List<UpdateAction> getActions(DeployableService currentService, DeployableServiceSpec newServiceSpec) {
DeployableServiceSpec currentServiceSpec = currentService.getSpec();
List<UpdateAction> actions = new ArrayList<UpdateAction>();
logger.info("Calculating changes on service spec \nOld = " + currentServiceSpec + "\nNew = " + newServiceSpec);
if (currentServiceSpec.getNumberOfInstances() < newServiceSpec.getNumberOfInstances()) {
UpdateAction action = new IncreaseNumberOfReplicas(currentService, newServiceSpec);
actions.add(action);
} else if (currentServiceSpec.getNumberOfInstances() > newServiceSpec.getNumberOfInstances()) {
UpdateAction action = new DecreaseNumberOfReplicas(currentService, newServiceSpec);
actions.add(action);
}
if (!(currentServiceSpec.getResourceImpact() == null || currentServiceSpec.getResourceImpact().getMemory() == null)) {
if (!(currentServiceSpec.getResourceImpact().getMemory().ordinal() == newServiceSpec.getResourceImpact()
.getMemory().ordinal())) {
UpdateAction action = new Migrate(currentService, newServiceSpec);
actions.add(action);
}
}
logger.info("Detected changes: " + actions);
return actions;
} |
1526495_9 | public List<UpdateAction> getActions(DeployableService currentService, DeployableServiceSpec newServiceSpec) {
DeployableServiceSpec currentServiceSpec = currentService.getSpec();
List<UpdateAction> actions = new ArrayList<UpdateAction>();
logger.info("Calculating changes on service spec \nOld = " + currentServiceSpec + "\nNew = " + newServiceSpec);
if (currentServiceSpec.getNumberOfInstances() < newServiceSpec.getNumberOfInstances()) {
UpdateAction action = new IncreaseNumberOfReplicas(currentService, newServiceSpec);
actions.add(action);
} else if (currentServiceSpec.getNumberOfInstances() > newServiceSpec.getNumberOfInstances()) {
UpdateAction action = new DecreaseNumberOfReplicas(currentService, newServiceSpec);
actions.add(action);
}
if (!(currentServiceSpec.getResourceImpact() == null || currentServiceSpec.getResourceImpact().getMemory() == null)) {
if (!(currentServiceSpec.getResourceImpact().getMemory().ordinal() == newServiceSpec.getResourceImpact()
.getMemory().ordinal())) {
UpdateAction action = new Migrate(currentService, newServiceSpec);
actions.add(action);
}
}
logger.info("Detected changes: " + actions);
return actions;
} |
152812_10 | public List<K> getKeysSortedByValue( final Comparator<V> comparator ) {
synchronized ( _map ) {
@SuppressWarnings( "unchecked" )
final
Entry<K, ManagedItem<V>>[] a = _map.entrySet().toArray( new Map.Entry[_map.size()] );
final Comparator<Entry<K, ManagedItem<V>>> c = new Comparator<Entry<K, ManagedItem<V>>>() {
@Override
public int compare( final Entry<K, ManagedItem<V>> o1, final Entry<K, ManagedItem<V>> o2 ) {
return comparator.compare( o1.getValue()._value, o2.getValue()._value );
}
};
Arrays.sort(a, c);
return new LRUCache.ArrayList<K, V>( a );
}
} |
152812_11 | public void clear() {
synchronized ( _map ) {
_map.clear();
}
} |
152812_12 | static int toMemcachedExpiration(final int expirationInSeconds) {
return expirationInSeconds <= THIRTY_DAYS ? expirationInSeconds : (int)(System.currentTimeMillis() / 1000) + expirationInSeconds;
} |
152812_13 | URI createURI(String redisUrl) throws URISyntaxException {
URI uri = new URI(redisUrl);
// set default port 6379 unless specified.
if (uri.getPort() < 0)
uri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), 6379, uri.getPath(), uri.getQuery(), uri.getFragment());
return uri;
} |
152812_14 | public List<String> getReadOnlyRequestsByFrequency() {
return _readOnlyRequests.getKeysSortedByValue( ATOMLONG_COMP );
} |
152812_15 | @Nonnull
public static MemcachedNodesManager createFor(final String memcachedNodes, final String failoverNodes, final StorageKeyFormat storageKeyFormat,
final StorageClientCallback storageClientCallback) {
if ( memcachedNodes == null || memcachedNodes.trim().isEmpty() ) {
throw new IllegalArgumentException("null or empty memcachedNodes not allowed.");
}
// Support a Redis URL in the form "redis://hostname:port" or "rediss://" (for SSL connections) like the client "Lettuce" does
if (memcachedNodes.startsWith("redis://") || memcachedNodes.startsWith("rediss://")) {
// Redis configuration
return new MemcachedNodesManager(memcachedNodes, new NodeIdList(), new ArrayList<String>(),
new LinkedHashMap<InetSocketAddress, String>(), storageKeyFormat, storageClientCallback);
}
if ( !NODES_PATTERN.matcher( memcachedNodes ).matches() && !SINGLE_NODE_PATTERN.matcher(memcachedNodes).matches()
&& !COUCHBASE_BUCKET_NODES_PATTERN.matcher(memcachedNodes).matches()) {
throw new IllegalArgumentException( "Configured memcachedNodes attribute has wrong format, must match " + NODES_REGEX );
}
final Matcher singleNodeMatcher = SINGLE_NODE_PATTERN.matcher(memcachedNodes);
// we have a linked hashmap to have insertion order for addresses
final LinkedHashMap<InetSocketAddress, String> address2Ids = new LinkedHashMap<InetSocketAddress, String>(1);
/**
* If mutliple nodes are configured
*/
if (singleNodeMatcher.matches()) { // for single
address2Ids.put(getSingleShortNodeDefinition(singleNodeMatcher), null);
}
else if (COUCHBASE_BUCKET_NODES_PATTERN.matcher(memcachedNodes).matches()) { // for couchbase
final Matcher matcher = COUCHBASE_BUCKET_NODE_PATTERN.matcher(memcachedNodes);
while (matcher.find()) {
final String hostname = matcher.group( 1 );
final int port = Integer.parseInt( matcher.group( 2 ) );
address2Ids.put(new InetSocketAddress( hostname, port ), null);
}
if (address2Ids.isEmpty()) {
throw new IllegalArgumentException("All nodes are also configured as failover nodes,"
+ " this is a configuration failure. In this case, you probably want to leave out the failoverNodes.");
}
}
else { // If mutliple nodes are configured
final Matcher matcher = NODE_PATTERN.matcher( memcachedNodes);
while (matcher.find()) {
final Pair<String, InetSocketAddress> nodeInfo = getRegularNodeDefinition(matcher);
address2Ids.put(nodeInfo.getSecond(), nodeInfo.getFirst());
}
if (address2Ids.isEmpty()) {
throw new IllegalArgumentException("All nodes are also configured as failover nodes,"
+ " this is a configuration failure. In this case, you probably want to leave out the failoverNodes.");
}
}
final List<String> failoverNodeIds = initFailoverNodes(failoverNodes, address2Ids.values());
// validate that for a single node there's no failover node specified as this does not make sense.
if(address2Ids.size() == 1 && failoverNodeIds.size() >= 1) {
throw new IllegalArgumentException("For a single memcached node there should/must no failoverNodes be specified.");
}
final NodeIdList primaryNodeIds = new NodeIdList();
for(final Map.Entry<InetSocketAddress, String> address2Id : address2Ids.entrySet()) {
final String nodeId = address2Id.getValue();
if (nodeId != null && !failoverNodeIds.contains(nodeId) ) {
primaryNodeIds.add(nodeId);
}
}
return new MemcachedNodesManager(memcachedNodes, primaryNodeIds, failoverNodeIds, address2Ids, storageKeyFormat, storageClientCallback);
} |
152812_16 | @Nonnull
public static MemcachedNodesManager createFor(final String memcachedNodes, final String failoverNodes, final StorageKeyFormat storageKeyFormat,
final StorageClientCallback storageClientCallback) {
if ( memcachedNodes == null || memcachedNodes.trim().isEmpty() ) {
throw new IllegalArgumentException("null or empty memcachedNodes not allowed.");
}
// Support a Redis URL in the form "redis://hostname:port" or "rediss://" (for SSL connections) like the client "Lettuce" does
if (memcachedNodes.startsWith("redis://") || memcachedNodes.startsWith("rediss://")) {
// Redis configuration
return new MemcachedNodesManager(memcachedNodes, new NodeIdList(), new ArrayList<String>(),
new LinkedHashMap<InetSocketAddress, String>(), storageKeyFormat, storageClientCallback);
}
if ( !NODES_PATTERN.matcher( memcachedNodes ).matches() && !SINGLE_NODE_PATTERN.matcher(memcachedNodes).matches()
&& !COUCHBASE_BUCKET_NODES_PATTERN.matcher(memcachedNodes).matches()) {
throw new IllegalArgumentException( "Configured memcachedNodes attribute has wrong format, must match " + NODES_REGEX );
}
final Matcher singleNodeMatcher = SINGLE_NODE_PATTERN.matcher(memcachedNodes);
// we have a linked hashmap to have insertion order for addresses
final LinkedHashMap<InetSocketAddress, String> address2Ids = new LinkedHashMap<InetSocketAddress, String>(1);
/**
* If mutliple nodes are configured
*/
if (singleNodeMatcher.matches()) { // for single
address2Ids.put(getSingleShortNodeDefinition(singleNodeMatcher), null);
}
else if (COUCHBASE_BUCKET_NODES_PATTERN.matcher(memcachedNodes).matches()) { // for couchbase
final Matcher matcher = COUCHBASE_BUCKET_NODE_PATTERN.matcher(memcachedNodes);
while (matcher.find()) {
final String hostname = matcher.group( 1 );
final int port = Integer.parseInt( matcher.group( 2 ) );
address2Ids.put(new InetSocketAddress( hostname, port ), null);
}
if (address2Ids.isEmpty()) {
throw new IllegalArgumentException("All nodes are also configured as failover nodes,"
+ " this is a configuration failure. In this case, you probably want to leave out the failoverNodes.");
}
}
else { // If mutliple nodes are configured
final Matcher matcher = NODE_PATTERN.matcher( memcachedNodes);
while (matcher.find()) {
final Pair<String, InetSocketAddress> nodeInfo = getRegularNodeDefinition(matcher);
address2Ids.put(nodeInfo.getSecond(), nodeInfo.getFirst());
}
if (address2Ids.isEmpty()) {
throw new IllegalArgumentException("All nodes are also configured as failover nodes,"
+ " this is a configuration failure. In this case, you probably want to leave out the failoverNodes.");
}
}
final List<String> failoverNodeIds = initFailoverNodes(failoverNodes, address2Ids.values());
// validate that for a single node there's no failover node specified as this does not make sense.
if(address2Ids.size() == 1 && failoverNodeIds.size() >= 1) {
throw new IllegalArgumentException("For a single memcached node there should/must no failoverNodes be specified.");
}
final NodeIdList primaryNodeIds = new NodeIdList();
for(final Map.Entry<InetSocketAddress, String> address2Id : address2Ids.entrySet()) {
final String nodeId = address2Id.getValue();
if (nodeId != null && !failoverNodeIds.contains(nodeId) ) {
primaryNodeIds.add(nodeId);
}
}
return new MemcachedNodesManager(memcachedNodes, primaryNodeIds, failoverNodeIds, address2Ids, storageKeyFormat, storageClientCallback);
} |
152812_17 | @Nonnull
public static MemcachedNodesManager createFor(final String memcachedNodes, final String failoverNodes, final StorageKeyFormat storageKeyFormat,
final StorageClientCallback storageClientCallback) {
if ( memcachedNodes == null || memcachedNodes.trim().isEmpty() ) {
throw new IllegalArgumentException("null or empty memcachedNodes not allowed.");
}
// Support a Redis URL in the form "redis://hostname:port" or "rediss://" (for SSL connections) like the client "Lettuce" does
if (memcachedNodes.startsWith("redis://") || memcachedNodes.startsWith("rediss://")) {
// Redis configuration
return new MemcachedNodesManager(memcachedNodes, new NodeIdList(), new ArrayList<String>(),
new LinkedHashMap<InetSocketAddress, String>(), storageKeyFormat, storageClientCallback);
}
if ( !NODES_PATTERN.matcher( memcachedNodes ).matches() && !SINGLE_NODE_PATTERN.matcher(memcachedNodes).matches()
&& !COUCHBASE_BUCKET_NODES_PATTERN.matcher(memcachedNodes).matches()) {
throw new IllegalArgumentException( "Configured memcachedNodes attribute has wrong format, must match " + NODES_REGEX );
}
final Matcher singleNodeMatcher = SINGLE_NODE_PATTERN.matcher(memcachedNodes);
// we have a linked hashmap to have insertion order for addresses
final LinkedHashMap<InetSocketAddress, String> address2Ids = new LinkedHashMap<InetSocketAddress, String>(1);
/**
* If mutliple nodes are configured
*/
if (singleNodeMatcher.matches()) { // for single
address2Ids.put(getSingleShortNodeDefinition(singleNodeMatcher), null);
}
else if (COUCHBASE_BUCKET_NODES_PATTERN.matcher(memcachedNodes).matches()) { // for couchbase
final Matcher matcher = COUCHBASE_BUCKET_NODE_PATTERN.matcher(memcachedNodes);
while (matcher.find()) {
final String hostname = matcher.group( 1 );
final int port = Integer.parseInt( matcher.group( 2 ) );
address2Ids.put(new InetSocketAddress( hostname, port ), null);
}
if (address2Ids.isEmpty()) {
throw new IllegalArgumentException("All nodes are also configured as failover nodes,"
+ " this is a configuration failure. In this case, you probably want to leave out the failoverNodes.");
}
}
else { // If mutliple nodes are configured
final Matcher matcher = NODE_PATTERN.matcher( memcachedNodes);
while (matcher.find()) {
final Pair<String, InetSocketAddress> nodeInfo = getRegularNodeDefinition(matcher);
address2Ids.put(nodeInfo.getSecond(), nodeInfo.getFirst());
}
if (address2Ids.isEmpty()) {
throw new IllegalArgumentException("All nodes are also configured as failover nodes,"
+ " this is a configuration failure. In this case, you probably want to leave out the failoverNodes.");
}
}
final List<String> failoverNodeIds = initFailoverNodes(failoverNodes, address2Ids.values());
// validate that for a single node there's no failover node specified as this does not make sense.
if(address2Ids.size() == 1 && failoverNodeIds.size() >= 1) {
throw new IllegalArgumentException("For a single memcached node there should/must no failoverNodes be specified.");
}
final NodeIdList primaryNodeIds = new NodeIdList();
for(final Map.Entry<InetSocketAddress, String> address2Id : address2Ids.entrySet()) {
final String nodeId = address2Id.getValue();
if (nodeId != null && !failoverNodeIds.contains(nodeId) ) {
primaryNodeIds.add(nodeId);
}
}
return new MemcachedNodesManager(memcachedNodes, primaryNodeIds, failoverNodeIds, address2Ids, storageKeyFormat, storageClientCallback);
} |
152812_18 | @Nonnull
public static MemcachedNodesManager createFor(final String memcachedNodes, final String failoverNodes, final StorageKeyFormat storageKeyFormat,
final StorageClientCallback storageClientCallback) {
if ( memcachedNodes == null || memcachedNodes.trim().isEmpty() ) {
throw new IllegalArgumentException("null or empty memcachedNodes not allowed.");
}
// Support a Redis URL in the form "redis://hostname:port" or "rediss://" (for SSL connections) like the client "Lettuce" does
if (memcachedNodes.startsWith("redis://") || memcachedNodes.startsWith("rediss://")) {
// Redis configuration
return new MemcachedNodesManager(memcachedNodes, new NodeIdList(), new ArrayList<String>(),
new LinkedHashMap<InetSocketAddress, String>(), storageKeyFormat, storageClientCallback);
}
if ( !NODES_PATTERN.matcher( memcachedNodes ).matches() && !SINGLE_NODE_PATTERN.matcher(memcachedNodes).matches()
&& !COUCHBASE_BUCKET_NODES_PATTERN.matcher(memcachedNodes).matches()) {
throw new IllegalArgumentException( "Configured memcachedNodes attribute has wrong format, must match " + NODES_REGEX );
}
final Matcher singleNodeMatcher = SINGLE_NODE_PATTERN.matcher(memcachedNodes);
// we have a linked hashmap to have insertion order for addresses
final LinkedHashMap<InetSocketAddress, String> address2Ids = new LinkedHashMap<InetSocketAddress, String>(1);
/**
* If mutliple nodes are configured
*/
if (singleNodeMatcher.matches()) { // for single
address2Ids.put(getSingleShortNodeDefinition(singleNodeMatcher), null);
}
else if (COUCHBASE_BUCKET_NODES_PATTERN.matcher(memcachedNodes).matches()) { // for couchbase
final Matcher matcher = COUCHBASE_BUCKET_NODE_PATTERN.matcher(memcachedNodes);
while (matcher.find()) {
final String hostname = matcher.group( 1 );
final int port = Integer.parseInt( matcher.group( 2 ) );
address2Ids.put(new InetSocketAddress( hostname, port ), null);
}
if (address2Ids.isEmpty()) {
throw new IllegalArgumentException("All nodes are also configured as failover nodes,"
+ " this is a configuration failure. In this case, you probably want to leave out the failoverNodes.");
}
}
else { // If mutliple nodes are configured
final Matcher matcher = NODE_PATTERN.matcher( memcachedNodes);
while (matcher.find()) {
final Pair<String, InetSocketAddress> nodeInfo = getRegularNodeDefinition(matcher);
address2Ids.put(nodeInfo.getSecond(), nodeInfo.getFirst());
}
if (address2Ids.isEmpty()) {
throw new IllegalArgumentException("All nodes are also configured as failover nodes,"
+ " this is a configuration failure. In this case, you probably want to leave out the failoverNodes.");
}
}
final List<String> failoverNodeIds = initFailoverNodes(failoverNodes, address2Ids.values());
// validate that for a single node there's no failover node specified as this does not make sense.
if(address2Ids.size() == 1 && failoverNodeIds.size() >= 1) {
throw new IllegalArgumentException("For a single memcached node there should/must no failoverNodes be specified.");
}
final NodeIdList primaryNodeIds = new NodeIdList();
for(final Map.Entry<InetSocketAddress, String> address2Id : address2Ids.entrySet()) {
final String nodeId = address2Id.getValue();
if (nodeId != null && !failoverNodeIds.contains(nodeId) ) {
primaryNodeIds.add(nodeId);
}
}
return new MemcachedNodesManager(memcachedNodes, primaryNodeIds, failoverNodeIds, address2Ids, storageKeyFormat, storageClientCallback);
} |
152812_19 | @Nonnull
public static MemcachedNodesManager createFor(final String memcachedNodes, final String failoverNodes, final StorageKeyFormat storageKeyFormat,
final StorageClientCallback storageClientCallback) {
if ( memcachedNodes == null || memcachedNodes.trim().isEmpty() ) {
throw new IllegalArgumentException("null or empty memcachedNodes not allowed.");
}
// Support a Redis URL in the form "redis://hostname:port" or "rediss://" (for SSL connections) like the client "Lettuce" does
if (memcachedNodes.startsWith("redis://") || memcachedNodes.startsWith("rediss://")) {
// Redis configuration
return new MemcachedNodesManager(memcachedNodes, new NodeIdList(), new ArrayList<String>(),
new LinkedHashMap<InetSocketAddress, String>(), storageKeyFormat, storageClientCallback);
}
if ( !NODES_PATTERN.matcher( memcachedNodes ).matches() && !SINGLE_NODE_PATTERN.matcher(memcachedNodes).matches()
&& !COUCHBASE_BUCKET_NODES_PATTERN.matcher(memcachedNodes).matches()) {
throw new IllegalArgumentException( "Configured memcachedNodes attribute has wrong format, must match " + NODES_REGEX );
}
final Matcher singleNodeMatcher = SINGLE_NODE_PATTERN.matcher(memcachedNodes);
// we have a linked hashmap to have insertion order for addresses
final LinkedHashMap<InetSocketAddress, String> address2Ids = new LinkedHashMap<InetSocketAddress, String>(1);
/**
* If mutliple nodes are configured
*/
if (singleNodeMatcher.matches()) { // for single
address2Ids.put(getSingleShortNodeDefinition(singleNodeMatcher), null);
}
else if (COUCHBASE_BUCKET_NODES_PATTERN.matcher(memcachedNodes).matches()) { // for couchbase
final Matcher matcher = COUCHBASE_BUCKET_NODE_PATTERN.matcher(memcachedNodes);
while (matcher.find()) {
final String hostname = matcher.group( 1 );
final int port = Integer.parseInt( matcher.group( 2 ) );
address2Ids.put(new InetSocketAddress( hostname, port ), null);
}
if (address2Ids.isEmpty()) {
throw new IllegalArgumentException("All nodes are also configured as failover nodes,"
+ " this is a configuration failure. In this case, you probably want to leave out the failoverNodes.");
}
}
else { // If mutliple nodes are configured
final Matcher matcher = NODE_PATTERN.matcher( memcachedNodes);
while (matcher.find()) {
final Pair<String, InetSocketAddress> nodeInfo = getRegularNodeDefinition(matcher);
address2Ids.put(nodeInfo.getSecond(), nodeInfo.getFirst());
}
if (address2Ids.isEmpty()) {
throw new IllegalArgumentException("All nodes are also configured as failover nodes,"
+ " this is a configuration failure. In this case, you probably want to leave out the failoverNodes.");
}
}
final List<String> failoverNodeIds = initFailoverNodes(failoverNodes, address2Ids.values());
// validate that for a single node there's no failover node specified as this does not make sense.
if(address2Ids.size() == 1 && failoverNodeIds.size() >= 1) {
throw new IllegalArgumentException("For a single memcached node there should/must no failoverNodes be specified.");
}
final NodeIdList primaryNodeIds = new NodeIdList();
for(final Map.Entry<InetSocketAddress, String> address2Id : address2Ids.entrySet()) {
final String nodeId = address2Id.getValue();
if (nodeId != null && !failoverNodeIds.contains(nodeId) ) {
primaryNodeIds.add(nodeId);
}
}
return new MemcachedNodesManager(memcachedNodes, primaryNodeIds, failoverNodeIds, address2Ids, storageKeyFormat, storageClientCallback);
} |
152812_20 | public boolean isEncodeNodeIdInSessionId() {
return _encodeNodeIdInSessionId;
} |
152812_21 | @Nonnull
public String getNodeId(final InetSocketAddress socketAddress) throws IllegalArgumentException {
if ( socketAddress == null ) {
throw new IllegalArgumentException("SocketAddress must not be null.");
}
final String result = _address2Ids.get( socketAddress );
if ( result == null ) {
throw new IllegalArgumentException("SocketAddress " + socketAddress + " not known (registered addresses: " + _address2Ids.keySet() + ").");
}
return result;
} |
152812_22 | @CheckForNull
public String getNextPrimaryNodeId(final String nodeId) {
return _primaryNodeIds.getNextNodeId(nodeId);
} |
152812_23 | public String getNextAvailableNodeId(final String nodeId) {
String result = nodeId;
do {
result = _primaryNodeIds.getNextNodeId(result);
if(result != null && result.equals(nodeId)) {
result = null;
}
} while(result != null && !isNodeAvailable(result));
return result;
} |
152812_24 | @Nonnull
public List<InetSocketAddress> getAllMemcachedAddresses() {
return new ArrayList<InetSocketAddress>( _address2Ids.keySet() );
} |
152812_25 | @Nonnull
public SessionIdFormat getSessionIdFormat() {
return _sessionIdFormat;
} |
152812_26 | public void setNodeAvailable(@Nullable final String nodeId, final boolean available) {
if ( _nodeIdService != null ) {
_nodeIdService.setNodeAvailable(nodeId, available);
}
} |
152812_27 | public boolean isCouchbaseBucketConfig() {
return COUCHBASE_BUCKET_NODES_PATTERN.matcher(_memcachedNodes).matches();
} |
152812_28 | public List<URI> getCouchbaseBucketURIs() {
if(!isCouchbaseBucketConfig())
throw new IllegalStateException("This is not a couchbase bucket configuration.");
final List<URI> result = new ArrayList<URI>(_address2Ids.size());
final Matcher matcher = COUCHBASE_BUCKET_NODE_PATTERN.matcher(_memcachedNodes);
while (matcher.find()) {
try {
result.add(new URI(matcher.group()));
} catch (final URISyntaxException e) {
throw new RuntimeException(e);
}
}
return result;
} |
152812_29 | public String changeSessionIdForTomcatFailover( @Nonnull final String sessionId, final String jvmRoute ) {
final String newSessionId = jvmRoute != null && !jvmRoute.trim().isEmpty()
? _sessionIdFormat.changeJvmRoute( sessionId, jvmRoute )
: _sessionIdFormat.stripJvmRoute(sessionId);
if ( isEncodeNodeIdInSessionId() ) {
final String nodeId = _sessionIdFormat.extractMemcachedId( newSessionId );
if(_failoverNodeIds != null && _failoverNodeIds.contains(nodeId)) {
final String newNodeId = _nodeIdService.getAvailableNodeId( nodeId );
if ( newNodeId != null ) {
return _sessionIdFormat.createNewSessionId( newSessionId, newNodeId);
}
}
}
return newSessionId;
} |
152812_30 | public static Statistics create() {
return create( true );
} |
152812_31 | public void register( @Nonnull final StatsType statsType, final long value ) {
_probes.get( statsType ).register( value );
} |
152812_32 | protected String getSessionCookieName() {
return _sessionCookieName;
} |
152812_33 | @Override
public void invoke( final Request request, final Response response ) throws IOException, ServletException {
final String requestId = getURIWithQueryString( request );
if(!_enabled.get() || !_msmContext.equals(request.getContext())) {
getNext().invoke( request, response );
} else if ( _ignorePattern != null && _ignorePattern.matcher( requestId ).matches() ) {
if(_log.isDebugEnabled()) {
_log.debug( ">>>>>> Ignoring: " + requestId + " (requestedSessionId "+ request.getRequestedSessionId() +") ==================" );
}
try {
storeRequestThreadLocal( request );
request.setNote(REQUEST_IGNORED, Boolean.TRUE);
getNext().invoke( request, response );
} finally {
if(request.getNote(REQUEST_PROCESSED) == Boolean.TRUE) {
final String sessionId = getSessionId(request, response);
if(sessionId != null) {
_sessionBackupService.requestFinished(sessionId, requestId);
}
}
resetRequestThreadLocal();
}
if(_log.isDebugEnabled()) {
_log.debug( "<<<<<< Ignored: " + requestId + " ==================" );
}
} else {
request.setNote(REQUEST_PROCESS, Boolean.TRUE);
if ( _log.isDebugEnabled() ) {
_log.debug( ">>>>>> Request starting: " + requestId + " (requestedSessionId "+ request.getRequestedSessionId() +") ==================" );
}
try {
storeRequestThreadLocal( request );
getNext().invoke( request, response );
} finally {
final Boolean sessionIdChanged = (Boolean) request.getNote(SESSION_ID_CHANGED);
backupSession( request, response, sessionIdChanged == null ? false : sessionIdChanged.booleanValue() );
resetRequestThreadLocal();
}
if ( _log.isDebugEnabled() ) {
logDebugRequestSessionCookie( request );
logDebugResponseCookie( response );
_log.debug( "<<<<<< Request finished: " + requestId + " ==================" );
}
}
} |
152812_34 | @Nonnull
public String createSessionId(@Nonnull final String sessionId, @Nullable final String memcachedId) {
if ( LOG.isDebugEnabled() ) {
LOG.debug( "Creating new session id with orig id '" + sessionId + "' and memcached id '" + memcachedId + "'." );
}
if ( memcachedId == null ) {
return sessionId;
}
final int idx = sessionId.indexOf( '.' );
if ( idx < 0 ) {
return sessionId + "-" + memcachedId;
} else {
return sessionId.substring( 0, idx ) + "-" + memcachedId + sessionId.substring( idx );
}
} |
152812_35 | @Nonnull
public String createNewSessionId( @Nonnull final String sessionId, @Nonnull final String newMemcachedId) {
final int idxDot = sessionId.indexOf( '.' );
if ( idxDot != -1 ) {
final String plainSessionId = sessionId.substring( 0, idxDot );
final String jvmRouteWithDot = sessionId.substring( idxDot );
return appendOrReplaceMemcachedId( plainSessionId, newMemcachedId ) + jvmRouteWithDot;
}
else {
return appendOrReplaceMemcachedId( sessionId, newMemcachedId );
}
} |
152812_36 | @CheckForNull
public String extractMemcachedId( @Nonnull final String sessionId ) {
final int idxDash = sessionId.indexOf( '-' );
if ( idxDash < 0 ) {
return null;
}
final int idxDot = sessionId.indexOf( '.' );
if ( idxDot < 0 ) {
return sessionId.substring( idxDash + 1 );
} else if ( idxDot < idxDash ) /* The dash was part of the jvmRoute */ {
return null;
} else {
return sessionId.substring( idxDash + 1, idxDot );
}
} |
152812_37 | public boolean isValid( @Nullable final String sessionId ) {
return sessionId != null && _pattern.matcher( sessionId ).matches();
} |
152812_38 | @Nonnull
public String createBackupKey( @Nonnull final String origKey ) {
if ( origKey == null ) {
throw new IllegalArgumentException( "The origKey must not be null." );
}
return BACKUP_PREFIX + _storageKeyFormat.format(origKey);
} |
152812_39 | public boolean isBackupKey( @Nonnull final String key ) {
return key.startsWith( BACKUP_PREFIX );
} |
152812_40 | @Nonnull
public String createLockName( @Nonnull final String sessionId ) {
if ( sessionId == null ) {
throw new IllegalArgumentException( "The sessionId must not be null." );
}
return "lock:" + _storageKeyFormat.format(sessionId);
} |
152812_41 | @Nonnull
public String createValidityInfoKeyName( @Nonnull final String origKey ) {
if ( origKey == null ) {
throw new IllegalArgumentException( "The sessionId must not be null." );
}
return "validity:" + _storageKeyFormat.format(origKey);
} |
152812_42 | @CheckForNull
public String getNextNodeId( @Nonnull final String nodeId ) throws IllegalArgumentException {
final int idx = indexOf( nodeId );
if ( idx < 0 ) {
throw new IllegalArgumentException( "The given node id "+ nodeId +" is not part of this list " + toString() );
}
if ( size() == 1 ) {
return null;
}
return ( idx == size() - 1 ) ? get( 0 ) : get( idx + 1 );
} |
152812_43 | public String getAvailableNodeId( final String nodeId ) {
String result = null;
/*
* first check regular nodes
*/
result = getRandomNextNodeId( nodeId, _nodeIds );
/*
* we got no node from the first nodes list, so we must check the
* alternative node list
*/
if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) {
result = getRandomNextNodeId( nodeId, _failoverNodeIds );
}
return result;
} |
152812_44 | public String getAvailableNodeId( final String nodeId ) {
String result = null;
/*
* first check regular nodes
*/
result = getRandomNextNodeId( nodeId, _nodeIds );
/*
* we got no node from the first nodes list, so we must check the
* alternative node list
*/
if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) {
result = getRandomNextNodeId( nodeId, _failoverNodeIds );
}
return result;
} |
152812_45 | public String getAvailableNodeId( final String nodeId ) {
String result = null;
/*
* first check regular nodes
*/
result = getRandomNextNodeId( nodeId, _nodeIds );
/*
* we got no node from the first nodes list, so we must check the
* alternative node list
*/
if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) {
result = getRandomNextNodeId( nodeId, _failoverNodeIds );
}
return result;
} |
152812_46 | public String getAvailableNodeId( final String nodeId ) {
String result = null;
/*
* first check regular nodes
*/
result = getRandomNextNodeId( nodeId, _nodeIds );
/*
* we got no node from the first nodes list, so we must check the
* alternative node list
*/
if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) {
result = getRandomNextNodeId( nodeId, _failoverNodeIds );
}
return result;
} |
152812_47 | public String getAvailableNodeId( final String nodeId ) {
String result = null;
/*
* first check regular nodes
*/
result = getRandomNextNodeId( nodeId, _nodeIds );
/*
* we got no node from the first nodes list, so we must check the
* alternative node list
*/
if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) {
result = getRandomNextNodeId( nodeId, _failoverNodeIds );
}
return result;
} |
152812_48 | public String getAvailableNodeId( final String nodeId ) {
String result = null;
/*
* first check regular nodes
*/
result = getRandomNextNodeId( nodeId, _nodeIds );
/*
* we got no node from the first nodes list, so we must check the
* alternative node list
*/
if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) {
result = getRandomNextNodeId( nodeId, _failoverNodeIds );
}
return result;
} |
152812_49 | public String getAvailableNodeId( final String nodeId ) {
String result = null;
/*
* first check regular nodes
*/
result = getRandomNextNodeId( nodeId, _nodeIds );
/*
* we got no node from the first nodes list, so we must check the
* alternative node list
*/
if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) {
result = getRandomNextNodeId( nodeId, _failoverNodeIds );
}
return result;
} |
1529680_0 | String getJavaCommand() {
if (configuration == null) {
throw new IllegalStateException("setup not called");
}
return configuration.getJavaHome() + File.separator + "bin" + File.separator + "java";
} |
1529680_1 | public String getJavaHome() {
return javaHome;
} |
1535924_0 | static boolean isReRegisterBuiltinNodeType(Exception e) {
return
(e instanceof RepositoryException)
& (e.getMessage() != null && e.getMessage().contains("reregister built-in node type"));
} |
1535924_1 | @Override
public void start( BundleContext bundleContext ) throws Exception {
this.bundleContext = bundleContext;
if (null == activatorHelper) {
this.activatorHelper = getActivatorHelper();
}
ServiceReference configurationAdminServiceReference = bundleContext.getServiceReference(CONFIG_ADMIN_NAME);
if (null != configurationAdminServiceReference) {
activatorHelper.verifyConfiguration(configurationAdminServiceReference);
} else {
bundleContext.addServiceListener(this, String.format("(%s=%s)", Constants.OBJECTCLASS, CONFIG_ADMIN_NAME));
}
AccessManagerFactoryTracker accessManagerFactoryTracker = getAccessManagerFactoryTracker();
if (null == accessManagerFactoryTracker) {
accessManagerFactoryTracker = this.accessManagerFactoryTracker = activatorHelper.createAccessManagerFactoryTracker();
}
accessManagerFactoryTracker.open();
ClassLoader bundleClassLoader = new BundleClassLoaderFactory(bundleContext).getClassLoader((String[])null);
I18n.setLocalizationRepository(new ClasspathLocalizationRepository(bundleClassLoader));
} |
1535924_2 | @Override
public void start( BundleContext bundleContext ) throws Exception {
this.bundleContext = bundleContext;
if (null == activatorHelper) {
this.activatorHelper = getActivatorHelper();
}
ServiceReference configurationAdminServiceReference = bundleContext.getServiceReference(CONFIG_ADMIN_NAME);
if (null != configurationAdminServiceReference) {
activatorHelper.verifyConfiguration(configurationAdminServiceReference);
} else {
bundleContext.addServiceListener(this, String.format("(%s=%s)", Constants.OBJECTCLASS, CONFIG_ADMIN_NAME));
}
AccessManagerFactoryTracker accessManagerFactoryTracker = getAccessManagerFactoryTracker();
if (null == accessManagerFactoryTracker) {
accessManagerFactoryTracker = this.accessManagerFactoryTracker = activatorHelper.createAccessManagerFactoryTracker();
}
accessManagerFactoryTracker.open();
ClassLoader bundleClassLoader = new BundleClassLoaderFactory(bundleContext).getClassLoader((String[])null);
I18n.setLocalizationRepository(new ClasspathLocalizationRepository(bundleClassLoader));
} |
1535924_3 | @Override
public void start( BundleContext bundleContext ) throws Exception {
this.bundleContext = bundleContext;
if (null == activatorHelper) {
this.activatorHelper = getActivatorHelper();
}
ServiceReference configurationAdminServiceReference = bundleContext.getServiceReference(CONFIG_ADMIN_NAME);
if (null != configurationAdminServiceReference) {
activatorHelper.verifyConfiguration(configurationAdminServiceReference);
} else {
bundleContext.addServiceListener(this, String.format("(%s=%s)", Constants.OBJECTCLASS, CONFIG_ADMIN_NAME));
}
AccessManagerFactoryTracker accessManagerFactoryTracker = getAccessManagerFactoryTracker();
if (null == accessManagerFactoryTracker) {
accessManagerFactoryTracker = this.accessManagerFactoryTracker = activatorHelper.createAccessManagerFactoryTracker();
}
accessManagerFactoryTracker.open();
ClassLoader bundleClassLoader = new BundleClassLoaderFactory(bundleContext).getClassLoader((String[])null);
I18n.setLocalizationRepository(new ClasspathLocalizationRepository(bundleClassLoader));
} |
1535924_4 | @Override
public void stop( BundleContext bundleContext ) throws Exception {
AccessManagerFactoryTracker managerFactoryTracker = getAccessManagerFactoryTracker();
if (null != managerFactoryTracker) {
managerFactoryTracker.close();
}
} |
1535924_5 | @Override
public void stop( BundleContext bundleContext ) throws Exception {
AccessManagerFactoryTracker managerFactoryTracker = getAccessManagerFactoryTracker();
if (null != managerFactoryTracker) {
managerFactoryTracker.close();
}
} |
1535924_6 | @Override
public void serviceChanged( ServiceEvent event ) {
if (ServiceEvent.REGISTERED == event.getType()) {
getActivatorHelper().verifyConfiguration(event.getServiceReference());
bundleContext.removeServiceListener(this);
}
} |
1535924_7 | @Override
public void serviceChanged( ServiceEvent event ) {
if (ServiceEvent.REGISTERED == event.getType()) {
getActivatorHelper().verifyConfiguration(event.getServiceReference());
bundleContext.removeServiceListener(this);
}
} |
1535924_8 | File getHomeDir() {
File homeDir;
String repoHomePath = bundleContext.getProperty(SLING_REPOSITORY_HOME);
String slingHomePath = bundleContext.getProperty(SLING_HOME);
String repositoryName = getRepositoryName();
if (repoHomePath != null) {
homeDir = new File(repoHomePath, repositoryName);
} else if (slingHomePath != null) {
homeDir = new File(slingHomePath, repositoryName);
} else {
homeDir = new File(repositoryName);
}
log.info("Creating default config for Modeshape in " + homeDir);
if (!homeDir.isDirectory()) {
if (!homeDir.mkdirs()) {
log.info("verifyConfiguration: Cannot create Modeshape home " + homeDir
+ ", failed creating default configuration");
return null;
}
}
return homeDir;
} |
1535924_9 | File getHomeDir() {
File homeDir;
String repoHomePath = bundleContext.getProperty(SLING_REPOSITORY_HOME);
String slingHomePath = bundleContext.getProperty(SLING_HOME);
String repositoryName = getRepositoryName();
if (repoHomePath != null) {
homeDir = new File(repoHomePath, repositoryName);
} else if (slingHomePath != null) {
homeDir = new File(slingHomePath, repositoryName);
} else {
homeDir = new File(repositoryName);
}
log.info("Creating default config for Modeshape in " + homeDir);
if (!homeDir.isDirectory()) {
if (!homeDir.mkdirs()) {
log.info("verifyConfiguration: Cannot create Modeshape home " + homeDir
+ ", failed creating default configuration");
return null;
}
}
return homeDir;
} |
1545929_0 | static ParameterTable parse(File file) throws IOException {
LOG.debug("parsing JSON parameter table: {}", file); //$NON-NLS-1$
JsonFactory json = new JsonFactory();
json.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
json.enable(JsonParser.Feature.ALLOW_COMMENTS);
json.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
json.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
json.enable(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER);
json.enable(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS);
try (JsonParser parser = json.createParser(file)) {
ParameterTable.Builder builder = IterativeExtensions.builder();
while (true) {
JsonToken t = parser.nextToken();
if (t == null) {
break;
} else if (t == JsonToken.START_OBJECT) {
builder.next();
parseRow(parser, builder);
} else {
throw new IOException(MessageFormat.format(
"invalid JSON format (invalid start object): {0}",
parser.getCurrentLocation()));
}
}
return builder.build();
}
} |
1545929_1 | static ParameterTable parse(File file) throws IOException {
LOG.debug("parsing JSON parameter table: {}", file); //$NON-NLS-1$
JsonFactory json = new JsonFactory();
json.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
json.enable(JsonParser.Feature.ALLOW_COMMENTS);
json.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
json.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
json.enable(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER);
json.enable(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS);
try (JsonParser parser = json.createParser(file)) {
ParameterTable.Builder builder = IterativeExtensions.builder();
while (true) {
JsonToken t = parser.nextToken();
if (t == null) {
break;
} else if (t == JsonToken.START_OBJECT) {
builder.next();
parseRow(parser, builder);
} else {
throw new IOException(MessageFormat.format(
"invalid JSON format (invalid start object): {0}",
parser.getCurrentLocation()));
}
}
return builder.build();
}
} |
1545929_2 | static ParameterTable parse(File file) throws IOException {
LOG.debug("parsing JSON parameter table: {}", file); //$NON-NLS-1$
JsonFactory json = new JsonFactory();
json.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
json.enable(JsonParser.Feature.ALLOW_COMMENTS);
json.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
json.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
json.enable(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER);
json.enable(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS);
try (JsonParser parser = json.createParser(file)) {
ParameterTable.Builder builder = IterativeExtensions.builder();
while (true) {
JsonToken t = parser.nextToken();
if (t == null) {
break;
} else if (t == JsonToken.START_OBJECT) {
builder.next();
parseRow(parser, builder);
} else {
throw new IOException(MessageFormat.format(
"invalid JSON format (invalid start object): {0}",
parser.getCurrentLocation()));
}
}
return builder.build();
}
} |
1545929_3 | @Override
public Extension handle(String tag, String value) throws IOException {
if (tag.equals(TAG) == false) {
return null;
}
File file = new File(value);
if (file.isFile() == false) {
throw new FileNotFoundException(file.getAbsolutePath());
}
ParameterTable table = parse(file);
File temporary = File.createTempFile("asakusa-iterative-", ".bin"); //$NON-NLS-1$ //$NON-NLS-2$
boolean success = false;
try (OutputStream output = new FileOutputStream(temporary)) {
LOG.debug("storing parameter table: {}", temporary); //$NON-NLS-1$
IterativeExtensions.save(output, table);
success = true;
} finally {
if (success == false) {
if (temporary.delete() == false && temporary.exists()) {
LOG.warn(MessageFormat.format(
"failed to delete temporary file: {0}", //$NON-NLS-1$
temporary));
}
}
}
return new BasicExtension(IterativeExtensions.EXTENSION_NAME, temporary, true);
} |
1545929_4 | @Override
public Extension handle(String tag, String value) throws IOException {
if (tag.equals(TAG) == false) {
return null;
}
File file = new File(value);
if (file.isFile() == false) {
throw new FileNotFoundException(file.getAbsolutePath());
}
ParameterTable table = parse(file);
File temporary = File.createTempFile("asakusa-iterative-", ".bin"); //$NON-NLS-1$ //$NON-NLS-2$
boolean success = false;
try (OutputStream output = new FileOutputStream(temporary)) {
LOG.debug("storing parameter table: {}", temporary); //$NON-NLS-1$
IterativeExtensions.save(output, table);
success = true;
} finally {
if (success == false) {
if (temporary.delete() == false && temporary.exists()) {
LOG.warn(MessageFormat.format(
"failed to delete temporary file: {0}", //$NON-NLS-1$
temporary));
}
}
}
return new BasicExtension(IterativeExtensions.EXTENSION_NAME, temporary, true);
} |
1545929_5 | @Override
public boolean isAvailable(String name) {
Objects.requireNonNull(name);
return toMap().containsKey(name);
} |
1545929_6 | @Override
public String get(String name) {
Objects.requireNonNull(name);
return toMap().get(name);
} |
1545929_7 | @Override
public Set<String> getAvailable() {
return toMap().keySet();
} |
1545929_8 | @Override
public List<ParameterSet> getRows() {
List<ParameterSet> results = new ArrayList<>();
for (ParameterSet element : this) {
results.add(element);
}
return results;
} |
1545929_9 | @Override
public List<ParameterSet> getRows() {
List<ParameterSet> results = new ArrayList<>();
for (ParameterSet element : this) {
results.add(element);
}
return results;
} |
1548514_0 | @Override
public List<MethodRef> getDeclaredMethods(RubyModule clazz) {
List<MethodRef> r = new ArrayList<MethodRef>();
for (DynamicMethod m : clazz.getMethods().values()) {
// TODO: not sure if this is entirely correct
if (m.getImplementationClass()==clazz)
r.add(new RubyMethodRef(clazz,m));
}
return r;
} |
1548514_1 | @Override
public List<FieldRef> getDeclaredFields(RubyModule clazz) {
// IIUC, Ruby doesn't have statically defined instance fields
return Collections.emptyList();
} |
1548514_2 | @Override
public List<Function> getFunctions(RubyModule clazz) {
// implemented as a fallback to Java through reified class, but maybe there's a better way to do this
return new ClassDescriptor(toJavaClass(clazz)).methods;
} |
1548514_3 | public String select(Iterable<String> supported) {
float bestQ = 0;
String best = null;
for (String s : supported) {
Atom a = match(s);
if (a!= null && a.q > bestQ) {
bestQ = a.q;
best = s;
}
}
if (best==null)
throw HttpResponses.error(HttpServletResponse.SC_NOT_ACCEPTABLE,
"Requested MIME types '" + ranges + "' didn't match any of the available options "+supported);
return best;
} |
1548514_4 | public String select(Iterable<String> supported) {
float bestQ = 0;
String best = null;
for (String s : supported) {
Atom a = match(s);
if (a!= null && a.q > bestQ) {
bestQ = a.q;
best = s;
}
}
if (best==null)
throw HttpResponses.error(HttpServletResponse.SC_NOT_ACCEPTABLE,
"Requested MIME types '" + ranges + "' didn't match any of the available options "+supported);
return best;
} |
1548514_5 | public String select(Iterable<String> supported) {
float bestQ = 0;
String best = null;
for (String s : supported) {
Atom a = match(s);
if (a!= null && a.q > bestQ) {
bestQ = a.q;
best = s;
}
}
if (best==null)
throw HttpResponses.error(HttpServletResponse.SC_NOT_ACCEPTABLE,
"Requested MIME types '" + ranges + "' didn't match any of the available options "+supported);
return best;
} |
1548514_6 | public String select(Iterable<String> supported) {
float bestQ = 0;
String best = null;
for (String s : supported) {
Atom a = match(s);
if (a!= null && a.q > bestQ) {
bestQ = a.q;
best = s;
}
}
if (best==null)
throw HttpResponses.error(HttpServletResponse.SC_NOT_ACCEPTABLE,
"Requested MIME types '" + ranges + "' didn't match any of the available options "+supported);
return best;
} |
1548514_7 | public String select(Iterable<String> supported) {
float bestQ = 0;
String best = null;
for (String s : supported) {
Atom a = match(s);
if (a!= null && a.q > bestQ) {
bestQ = a.q;
best = s;
}
}
if (best==null)
throw HttpResponses.error(HttpServletResponse.SC_NOT_ACCEPTABLE,
"Requested MIME types '" + ranges + "' didn't match any of the available options "+supported);
return best;
} |
1548514_8 | public String select(Iterable<String> supported) {
float bestQ = 0;
String best = null;
for (String s : supported) {
Atom a = match(s);
if (a!= null && a.q > bestQ) {
bestQ = a.q;
best = s;
}
}
if (best==null)
throw HttpResponses.error(HttpServletResponse.SC_NOT_ACCEPTABLE,
"Requested MIME types '" + ranges + "' didn't match any of the available options "+supported);
return best;
} |
1548514_9 | public String select(Iterable<String> supported) {
float bestQ = 0;
String best = null;
for (String s : supported) {
Atom a = match(s);
if (a!= null && a.q > bestQ) {
bestQ = a.q;
best = s;
}
}
if (best==null)
throw HttpResponses.error(HttpServletResponse.SC_NOT_ACCEPTABLE,
"Requested MIME types '" + ranges + "' didn't match any of the available options "+supported);
return best;
} |
1549503_0 | public ExpiryPolicy getExpiryPolicy() {
return expiryPolicy;
} |
1549503_1 | @Override
public <T> T unwrap(final Class<T> clazz) {
if(clazz.isAssignableFrom(getClass())) {
return clazz.cast(this);
}
if(clazz.isAssignableFrom(cacheManager.getClass())) {
return clazz.cast(cacheManager);
}
throw new IllegalArgumentException();
} |
1549503_2 | @Override
public <T> T unwrap(final Class<T> clazz) {
if(clazz.isAssignableFrom(getClass())) {
return clazz.cast(this);
}
if(clazz.isAssignableFrom(cacheManager.getClass())) {
return clazz.cast(cacheManager);
}
throw new IllegalArgumentException();
} |
1549503_3 | @Override
public CacheManager getCacheManager() {
return getCacheManager(getDefaultURI(), getDefaultClassLoader());
} |
1549503_4 | @Override
public CacheManager getCacheManager() {
return getCacheManager(getDefaultURI(), getDefaultClassLoader());
} |
1549503_5 | void shutdown(final JCacheManager jCacheManager) {
synchronized (cacheManagers) {
final ConcurrentMap<URI, JCacheManager> map = cacheManagers.get(jCacheManager.getClassLoader());
if(map != null && map.remove(jCacheManager.getURI()) != null) {
jCacheManager.shutdown();
}
}
} |
1551432_0 | static public Set<String> getNames(InputStream is) throws IOException {
Set<String> names = new HashSet<String>();
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is));
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
if (!entry.isDirectory())
names.add(entry.getName());
}
zis.close();
return names;
} |
1551432_1 | static public Set<String> getApacheNames(InputStream is) throws IOException, ArchiveException {
Set<String> names = new HashSet<String>();
ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(is);
ArchiveEntry entry;
while ((entry = ais.getNextEntry()) != null) {
if (!entry.isDirectory())
names.add(entry.getName());
}
ais.close();
return names;
} |
1551432_2 | public void parseMets(String folderName, String metsName) throws DocumentException, IOException {
SAXReader saxReader = new SAXReader();
Document metsDoc = saxReader.read(new InputStreamReader(new FileInputStream(folderName+metsName), "UTF-8"));
Element rootElt = metsDoc.getRootElement();
otElt.addNamespace("mets", "http://www.loc.gov/METS/");
otElt.addNamespace("xlink", "http://www.w3.org/1999/xlink");
ement imgGrpElt = (Element) rootElt.selectSingleNode("//mets:fileGrp[@ID='IMGGRP']");
de imgZipAtt = imgGrpElt.selectSingleNode("//mets:file[@ID='ZIPJP2']/mets:FLocat/@xlink:href");
st<Node> fileElements4Img = imgGrpElt.selectNodes("mets:file/mets:file/mets:FLocat/@xlink:href");
t<String> imgNameSetFromMets = new HashSet<String>();
r(Node file: fileElements4Img){
mgNameSetFromMets.add(formatImgMetsFilename(file.getText()));
ring imgZipFileName = folderName + imgZipAtt.getText() + ".dat";
t<String> imgFileNameSetInZip = ArchiveParser.getNames(new FileInputStream(imgZipFileName));
mpareImgSets(imgNameSetFromMets, imgFileNameSetInZip);
ement altoGrpElt = (Element) rootElt.selectSingleNode("//mets:fileGrp[@ID='ALTOGRP']");
de altoZipAtt = altoGrpElt.selectSingleNode("//mets:file[@ID='ZIPALTO']/mets:FLocat/@xlink:href");
st<Node> fileElements4Alto = altoGrpElt.selectNodes("mets:file/mets:file/mets:FLocat/@xlink:href");
t<String> altoNameSetFromMets = new HashSet<String>();
r(Node file: fileElements4Alto){
ltoNameSetFromMets.add(formatAltoMetsFilename(file.getText()));
ring altoZipFileName = folderName + altoZipAtt.getText() + ".dat";
t<String> altoFileNameSetInZip = ArchiveParser.getNames(new FileInputStream(altoZipFileName));
mpareAltoSets(altoNameSetFromMets, altoFileNameSetInZip);
de pdfFileElt = rootElt.selectSingleNode("//mets:fileGrp[@ID='PDFGRP']/mets:file/mets:FLocat/@xlink:href");
ring pdfFile = pdfFileElt.getText() + ".dat";
t numOfPages = PdfParser.getNumOfPages(folderName + pdfFile);
(numOfPages!=altoFileNameSetInZip.size() || numOfPages!=imgFileNameSetInZip.size())
his.misMatchPage = numOfPages + "," + imgFileNameSetInZip.size() + "," + altoFileNameSetInZip.size();
} |
1551432_3 | public static List<String> getFileLisst() {
if (fileList.size() == 0)
FileListLoader.load();
return fileList;
} |
1551432_4 | public static int getNumOfPages(String pdfFile) throws IOException {
PDDocument pdf = PDDocument.load(new File(pdfFile));
int count = pdf.getNumberOfPages();
pdf.close();
return count;
} |
1553760_0 | @Override
public String generateId(String headingText) {
String id = headingText.toLowerCase(Locale.getDefault());
id = id.replaceAll("[^a-z0-9_-]", "-"); //$NON-NLS-1$//$NON-NLS-2$
CharMatcher hyphenMatcher = CharMatcher.is('-');
id = hyphenMatcher.trimFrom(hyphenMatcher.collapseFrom(id, '-'));
return id;
} |
1553760_1 | @Override
public String generateId(String headingText) {
String id = headingText.toLowerCase(Locale.getDefault());
id = id.replaceAll("[^a-z0-9_-]", "-"); //$NON-NLS-1$//$NON-NLS-2$
CharMatcher hyphenMatcher = CharMatcher.is('-');
id = hyphenMatcher.trimFrom(hyphenMatcher.collapseFrom(id, '-'));
return id;
} |
1553760_2 | @Override
public String generateId(String headingText) {
String id = headingText.toLowerCase(Locale.getDefault());
id = id.replaceAll("[^a-z0-9_-]", "-"); //$NON-NLS-1$//$NON-NLS-2$
CharMatcher hyphenMatcher = CharMatcher.is('-');
id = hyphenMatcher.trimFrom(hyphenMatcher.collapseFrom(id, '-'));
return id;
} |
1553760_3 | @Override
public String generateId(String headingText) {
String id = headingText.toLowerCase(Locale.getDefault());
id = id.replaceAll("[^a-z0-9_-]", "-"); //$NON-NLS-1$//$NON-NLS-2$
CharMatcher hyphenMatcher = CharMatcher.is('-');
id = hyphenMatcher.trimFrom(hyphenMatcher.collapseFrom(id, '-'));
return id;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.