Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-6554 XML configuration converter for 6.0 files
- Loading branch information
1 parent
0741b9e
commit c03b784
Showing
22 changed files
with
4,106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
tools/src/main/java/org/infinispan/tools/config/ConfigurationConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
165
tools/src/main/java/org/infinispan/tools/config/v6/Attribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
105
tools/src/main/java/org/infinispan/tools/config/v6/Element.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
Oops, something went wrong.