Skip to content

Commit

Permalink
ISPN-6554 XML configuration converter for 6.0 files
Browse files Browse the repository at this point in the history
  • Loading branch information
tristantarrant committed May 9, 2016
1 parent 0741b9e commit c03b784
Show file tree
Hide file tree
Showing 22 changed files with 4,106 additions and 3 deletions.
4 changes: 4 additions & 0 deletions documentation/src/main/asciidoc/upgrading/upgrading.adoc
Expand Up @@ -102,6 +102,10 @@ As such all of these classes have been moved into a new package org.infinispan.f

The new org.infinispan.filter.KeyFilter interface has replaced both of the previous interfaces and all previous references use the new interface.

=== Declarative configuration

The XML schema for the embedded configuration has changed to more closely follow the server configuration. Use the `config-converter.sh` or `config-converter.bat` scripts to convert an Infinispan 6.0 to the current format.

== Upgrading from 5.3 to 6.0
=== Declarative configuration
In order to use all of the latest features, make sure you change the namespace declaration at the top of your XML configuration files as follows:
Expand Down
Expand Up @@ -62,4 +62,34 @@ public String toString() {
+ testWhileIdle + "]";
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

ConnectionPoolConfiguration that = (ConnectionPoolConfiguration) o;

if (maxActive != that.maxActive) return false;
if (maxTotal != that.maxTotal) return false;
if (maxIdle != that.maxIdle) return false;
if (minIdle != that.minIdle) return false;
if (timeBetweenEvictionRuns != that.timeBetweenEvictionRuns) return false;
if (minEvictableIdleTime != that.minEvictableIdleTime) return false;
if (testWhileIdle != that.testWhileIdle) return false;
return exhaustedAction == that.exhaustedAction;

}

@Override
public int hashCode() {
int result = exhaustedAction != null ? exhaustedAction.hashCode() : 0;
result = 31 * result + maxActive;
result = 31 * result + maxTotal;
result = 31 * result + maxIdle;
result = 31 * result + minIdle;
result = 31 * result + (int) (timeBetweenEvictionRuns ^ (timeBetweenEvictionRuns >>> 32));
result = 31 * result + (int) (minEvictableIdleTime ^ (minEvictableIdleTime >>> 32));
result = 31 * result + (testWhileIdle ? 1 : 0);
return result;
}
}
@@ -1,6 +1,8 @@
package org.infinispan.persistence.remote.configuration;

import org.infinispan.configuration.cache.StoreConfiguration;
import org.infinispan.configuration.serializer.AbstractConfigurationSerializerTest;
import org.testng.AssertJUnit;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

Expand All @@ -13,4 +15,12 @@ public Object[][] configurationFiles() {
{"remote-cl-config.xml"}
};
}

@Override
protected void compareStoreConfiguration(String name, StoreConfiguration beforeStore, StoreConfiguration afterStore) {
super.compareStoreConfiguration(name, beforeStore, afterStore);
RemoteStoreConfiguration before = (RemoteStoreConfiguration) beforeStore;
RemoteStoreConfiguration after = (RemoteStoreConfiguration) afterStore;
AssertJUnit.assertEquals("Wrong connection pool for " + name + " configuration.", before.connectionPool(), after.connectionPool());
}
}
@@ -0,0 +1,59 @@
package org.infinispan.tools.config;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.infinispan.Version;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.parsing.ConfigurationBuilderHolder;
import org.infinispan.configuration.parsing.ParserRegistry;

/**
* ConfigurationConverter.
*
* @author Tristan Tarrant
* @since 9.0
*/
public class ConfigurationConverter {

public static void convert(InputStream is, OutputStream os) throws Exception {
ParserRegistry registry = new ParserRegistry();
ConfigurationBuilderHolder configHolder = registry.parse(is);
Map<String, Configuration> configurations = new HashMap<>();
for(Entry<String, ConfigurationBuilder> config : configHolder.getNamedConfigurationBuilders().entrySet()) {
configurations.put(config.getKey(), config.getValue().build());
}
registry.serialize(os, configHolder.getGlobalConfigurationBuilder().build(), configurations);
}

public static final void main(String args[]) throws Exception {
InputStream is = null;
OutputStream os = null;
switch(args.length) {
case 0:
is = System.in;
os = System.out;
break;
case 1:
is = new FileInputStream(args[0]);
os = System.out;
break;
case 2:
is = new FileInputStream(args[0]);
os = new FileOutputStream(args[1]);
break;
default:
System.err.printf("Infinispan configuration converter v%s\n", Version.getVersion());
System.err.println("Usage: converter [input [output]]");
System.exit(1);
}
convert(is, os);
}

}
165 changes: 165 additions & 0 deletions tools/src/main/java/org/infinispan/tools/config/v6/Attribute.java
@@ -0,0 +1,165 @@
package org.infinispan.tools.config.v6;

import java.util.HashMap;
import java.util.Map;

/**
* Enumerates the attributes used in Infinispan
*
* @author Pete Muir
*/
public enum Attribute {
// must be first
UNKNOWN(null),

AFTER("after"),
ALLOW_DUPLICATE_DOMAINS("allowDuplicateDomains"),
ALWAYS_PROVIDE_IN_MEMORY_STATE("alwaysProvideInMemoryState"),
ASYNC_MARSHALLING("asyncMarshalling"),
AUTO_COMMIT("autoCommit"),
BEFORE("before"),
CACHE_MANAGER_NAME("cacheManagerName"),
CACHE_STOP_TIMEOUT("cacheStopTimeout"),
CAPACITY_FACTOR("capacityFactor"),
CHUNK_SIZE("chunkSize"),
CLASS("class"),
CLUSTER_NAME("clusterName"),
CONCURRENCY_LEVEL("concurrencyLevel"),
DISTRIBUTED_SYNC_TIMEOUT("distributedSyncTimeout"),
EAGER_LOCK_SINGLE_NODE("eagerLockSingleNode"),
ENABLED("enabled"),
EXTERNALIZER_CLASS("externalizerClass"),
FACTORY("factory"),
FETCH_IN_MEMORY_STATE("fetchInMemoryState"),
FETCH_PERSISTENT_STATE("fetchPersistentState"),
AWAIT_INITIAL_TRANSFER("awaitInitialTransfer"),
FLUSH_LOCK_TIMEOUT("flushLockTimeout"),
FSYNC_INTERVAL("fsyncInterval"),
FSYNC_MODE("fsyncMode"),
HASH_FUNCTION_CLASS("hashFunctionClass"),
HASH_SEED_CLASS("hashSeedClass"),
HOOK_BEHAVIOR("hookBehavior"),
ID("id"),
IGNORE_MODIFICATIONS("ignoreModifications"),
INDEX("index"),
INDEX_LOCAL_ONLY("indexLocalOnly"),
INITIAL_RETRY_WAIT_TIME("initialRetryWaitTime"),
INVALIDATION_THRESHOLD("invalidationThreshold"),
ISOLATION_LEVEL("isolationLevel"),
JMX_DOMAIN("jmxDomain"),
LIFESPAN("lifespan"),
LOCATION("location"),
INVALIDATION_CLEANUP_TASK_FREQUENCY("cleanupTaskFrequency"),
LOCK_ACQUISITION_TIMEOUT("lockAcquisitionTimeout"),
LOCKING_MODE("lockingMode"),
LOG_FLUSH_TIMEOUT("logFlushTimeout"),
MACHINE_ID("machineId"),
MARSHALLER_CLASS("marshallerClass"),
MAX_ENTRIES("maxEntries"),
MAX_IDLE("maxIdle"),
MAX_NON_PROGRESSING_LOG_WRITES("maxProgressingLogWrites"),
MBEAN_SERVER_LOOKUP("mBeanServerLookup"),
MODE("mode"),
NODE_NAME("nodeName"),
MODIFICATION_QUEUE_SIZE("modificationQueueSize"),
NAME("name"),
NUM_OWNERS("numOwners"),
NUM_SEGMENTS("numSegments"),
NUM_RETRIES("numRetries"),
NUM_VIRTUAL_NODES("numVirtualNodes"),
ON_REHASH("onRehash"),
PASSIVATION("passivation"),
POSITION("position"),
PRELOAD("preload"),
PURGE_ON_STARTUP("purgeOnStartup"),
PUSH_STATE_TIMEOUT("pushStateTimeout"),
PUSH_STATE_WHEN_COORDINATOR("pushStateWhenCoordinator"),
RACK_ID("rackId"),
REAPER_ENABLED("reaperEnabled"),
RECOVERY_INFO_CACHE_NAME("recoveryInfoCacheName"),
REHASH_ENABLED("rehashEnabled"),
REHASH_RPC_TIMEOUT("rehashRpcTimeout"),
REHASH_WAIT("rehashWait"),
REMOTE_CALL_TIMEOUT("remoteCallTimeout"),
REPL_QUEUE_INTERVAL("replQueueInterval"),
REPL_QUEUE_CLASS("replQueueClass"),
REPL_QUEUE_MAX_ELEMENTS("replQueueMaxElements"),
REPL_TIMEOUT("replTimeout"),
RETRY_WAIT_TIME_INCREASE_FACTOR("retryWaitTimeIncreaseFactor"),
SHARED("shared"),
SHUTDOWN_TIMEOUT("shutdownTimeout"),
SITE_ID("siteId"),
SPIN_DURATION("spinDuration"),
STORE_KEYS_AS_BINARY("storeKeysAsBinary"),
STORE_VALUES_AS_BINARY("storeValuesAsBinary"),
DEFENSIVE("defensive"),
STRATEGY("strategy"),
STREAM_BUFFER_SIZE("streamBufferSize"),
SYNC_COMMIT_PHASE("syncCommitPhase"),
SYNC_ROLLBACK_PHASE("syncRollbackPhase"),
STRICT_PEER_TO_PEER("strictPeerToPeer"),
THREAD_POLICY("threadPolicy"),
THREAD_POOL_SIZE("threadPoolSize"),
TIMEOUT("timeout"),
TRANSACTION_MANAGER_LOOKUP_CLASS("transactionManagerLookupClass"),
TRANSACTION_MODE("transactionMode"),
TRANSPORT_CLASS("transportClass"),
UNRELIABLE_RETURN_VALUES("unreliableReturnValues"),
USE_EAGER_LOCKING("useEagerLocking"),
USE_LOCK_STRIPING("useLockStriping"),
SUPPORTS_CONCURRENT_UPDATES("supportsConcurrentUpdates"),
USE_REPL_QUEUE("useReplQueue"),
USE_SYNCHRONIZAION("useSynchronization"),
VALUE("value"),
VERSION("version"),
WAKE_UP_INTERVAL("wakeUpInterval"),
WRITE_SKEW_CHECK("writeSkewCheck"),
USE_1PC_FOR_AUTOCOMMIT_TX("use1PcForAutoCommitTransactions"),
VERSIONING_SCHEME("versioningScheme"),
SITE("site"),
BACKUP_FAILURE_POLICY("backupFailurePolicy"),
REMOTE_SITE("remoteSite"),
REMOTE_CACHE("remoteCache"),
FAILURE_POLICY_CLASS("failurePolicyClass"),
BACKUP_SITES("backupSites"),
AFTER_FAILURES("afterFailures"),
MIN_TIME_TO_WAIT("minTimeToWait"),
USE_TWO_PHASE_COMMIT("useTwoPhaseCommit"),
REAPER_WAKE_UP_INTERVAL("reaperWakeUpInterval"),
COMPLETED_TX_TIMEOUT("completedTxTimeout"),
TRANSACTION_PROTOCOL("transactionProtocol"),
KEY_EQUIVALENCE("keyEquivalence"),
VALUE_EQUIVALENCE("valueEquivalence"),
TYPE_CONVERTER("typeConverter"), PURGE_SYNCHRONOUSLY("purgeSynchronously"), PURGER_THREADS("purgerThreads");

private final String name;

private Attribute(final String name) {
this.name = name;
}

/**
* Get the local name of this element.
*
* @return the local name
*/
public String getLocalName() {
return name;
}

private static final Map<String, Attribute> attributes;

static {
final Map<String, Attribute> map = new HashMap<String, Attribute>(64);
for (Attribute attribute : values()) {
final String name = attribute.getLocalName();
if (name != null) map.put(name, attribute);
}
attributes = map;
}

public static Attribute forName(String localName) {
final Attribute attribute = attributes.get(localName);
return attribute == null ? UNKNOWN : attribute;
}
}
105 changes: 105 additions & 0 deletions tools/src/main/java/org/infinispan/tools/config/v6/Element.java
@@ -0,0 +1,105 @@
package org.infinispan.tools.config.v6;

import java.util.HashMap;
import java.util.Map;

/**
* An enumeration of all the recognized XML element local names, by name.
*
* @author Pete Muir
*/
public enum Element {
// must be first
UNKNOWN(null),

//
ADVANCED_EXTERNALIZER("advancedExternalizer"),
ADVANCED_EXTERNALIZERS("advancedExternalizers"),
ASYNC("async"),
ASYNC_LISTENER_EXECUTOR("asyncListenerExecutor"),
PERSISTENCE_EXECUTOR("persistenceExecutor"),
ASYNC_TRANSPORT_EXECUTOR("asyncTransportExecutor"),
REMOTE_COMMAND_EXECUTOR("remoteCommandsExecutor"),
CLUSTERING("clustering"),
CLUSTER_STORE("cluster"),
COMPATIBILITY("compatibility"),
CUSTOM_INTERCEPTORS("customInterceptors"),
DATA_CONTAINER("dataContainer"),
DEADLOCK_DETECTION("deadlockDetection"),
DEFAULT("default"),
EVICTION("eviction"),
EVICTION_SCHEDULED_EXECUTOR("evictionScheduledExecutor"),
EXPIRATION("expiration"),
SINGLE_FILE_STORE("singleFile"),
GROUPS("groups"),
GROUPER("grouper"),
GLOBAL("global"),
GLOBAL_JMX_STATISTICS("globalJmxStatistics"),
HASH("hash"),
INDEXING("indexing"),
INTERCEPTOR("interceptor"),
INVOCATION_BATCHING("invocationBatching"),
JMX_STATISTICS("jmxStatistics"),
L1("l1"),
LAZY_DESERIALIZATION("lazyDeserialization"),
PERSISTENCE("persistence"),
LOCKING("locking"),
MODULES("modules"),
NAMED_CACHE("namedCache"),
PROPERTIES("properties"),
PROPERTY("property"),
RECOVERY("recovery"),
REPLICATION_QUEUE_SCHEDULED_EXECUTOR("replicationQueueScheduledExecutor"),
ROOT("infinispan"),
SERIALIZATION("serialization"),
SHUTDOWN("shutdown"),
SINGLETON_STORE("singleton"),
STATE_RETRIEVAL("stateRetrieval"),
STATE_TRANSFER("stateTransfer"),
STORE("store"),
STORE_AS_BINARY("storeAsBinary"),
SYNC("sync"),
TRANSACTION("transaction"),
TRANSPORT("transport"),
UNSAFE("unsafe"),
VERSIONING("versioning"),
SITES("sites"),
SITE("site"),
BACKUPS("backups"),
BACKUP("backup"),
BACKUP_FOR("backupFor"),
TAKE_OFFLINE("takeOffline"),
TOTAL_ORDER_EXECUTOR("totalOrderExecutor"),
;

private final String name;

Element(final String name) {
this.name = name;
}

/**
* Get the local name of this element.
*
* @return the local name
*/
public String getLocalName() {
return name;
}

private static final Map<String, Element> MAP;

static {
final Map<String, Element> map = new HashMap<String, Element>(8);
for (Element element : values()) {
final String name = element.getLocalName();
if (name != null) map.put(name, element);
}
MAP = map;
}

public static Element forName(String localName) {
final Element element = MAP.get(localName);
return element == null ? UNKNOWN : element;
}
}

0 comments on commit c03b784

Please sign in to comment.