JBoss Cache SVN: r6971 - enterprise-docs/tags/JBoss_EAP_4_3/Cache_Pojo_Cache_Guide/pt-BR.
by jbosscache-commits@lists.jboss.org
Author: ldelima(a)redhat.com
Date: 2008-10-15 23:22:27 -0400 (Wed, 15 Oct 2008)
New Revision: 6971
Modified:
enterprise-docs/tags/JBoss_EAP_4_3/Cache_Pojo_Cache_Guide/pt-BR/Appendix.po
enterprise-docs/tags/JBoss_EAP_4_3/Cache_Pojo_Cache_Guide/pt-BR/Architecture.po
Log:
translation ongoing
Modified: enterprise-docs/tags/JBoss_EAP_4_3/Cache_Pojo_Cache_Guide/pt-BR/Appendix.po
===================================================================
--- enterprise-docs/tags/JBoss_EAP_4_3/Cache_Pojo_Cache_Guide/pt-BR/Appendix.po 2008-10-16 01:37:09 UTC (rev 6970)
+++ enterprise-docs/tags/JBoss_EAP_4_3/Cache_Pojo_Cache_Guide/pt-BR/Appendix.po 2008-10-16 03:22:27 UTC (rev 6971)
@@ -9,7 +9,7 @@
"Project-Id-Version: Appendix\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2008-09-21 04:57+0000\n"
-"PO-Revision-Date: 2008-10-09 14:19+1000\n"
+"PO-Revision-Date: 2008-10-16 13:19+1000\n"
"Last-Translator: Leticia de Lima <ldelima(a)redhat.com>\n"
"Language-Team: Brazilian Portuguese <en(a)li.org>\n"
"MIME-Version: 1.0\n"
@@ -38,7 +38,7 @@
"are their defintion (note that neither class implements "
"<literal>Serializable</literal> )."
msgstr ""
-"As classes do POJO de amostra utilizadas são: literal>Person,</"
+"As classes do POJO de amostra utilizadas são: <literal>Person,</"
"literal><literal>Student,</literal> e <literal>Address</literal>. Segue abaixo as definições das mesmas (perceba que nenhuma das classes implementa a <literal>Serializable</literal>)."
#. Tag: programlisting
Modified: enterprise-docs/tags/JBoss_EAP_4_3/Cache_Pojo_Cache_Guide/pt-BR/Architecture.po
===================================================================
--- enterprise-docs/tags/JBoss_EAP_4_3/Cache_Pojo_Cache_Guide/pt-BR/Architecture.po 2008-10-16 01:37:09 UTC (rev 6970)
+++ enterprise-docs/tags/JBoss_EAP_4_3/Cache_Pojo_Cache_Guide/pt-BR/Architecture.po 2008-10-16 03:22:27 UTC (rev 6971)
@@ -9,7 +9,7 @@
"Project-Id-Version: Architecture\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2008-09-21 04:57+0000\n"
-"PO-Revision-Date: 2008-10-10 14:52+1000\n"
+"PO-Revision-Date: 2008-10-16 13:21+1000\n"
"Last-Translator: Leticia de Lima <ldelima(a)redhat.com>\n"
"Language-Team: Brazilian Portuguese <en(a)li.org>\n"
"MIME-Version: 1.0\n"
@@ -700,7 +700,7 @@
"operations."
msgstr ""
"As classes de POJO que herdam do <literal>Set</literal> , <literal>List</"
-"literal> e <literal>Map</literal> são automaticamente tratadas como \"posicionadas\". Isto é, os usuários não precisão tratá-las como \"preparadas\" no arquivo de configuração xml ou através da anotação. Uma vez que nós não somos autorizados a instrumentar a biblioteca de sistema Java, usaremos a abordagem proxy. Quando encontramos qualquer instância de Coleção, iremos <listitem> "
+"literal> e <literal>Map</literal> são automaticamente tratadas como \"posicionadas\". Isto é, os usuários não precisão tratá-las como \"preparadas\" no arquivo de configuração xml ou através da anotação. Uma vez que nós não somos autorizados a instrumentar a biblioteca de sistema Java, usaremos a abordagem proxy. Quando encontramos qualquer instância de Coleção, iremos <itemizedlist> <listitem> "
"<para>Criar a instância do proxy de Coleção e colocá-la no cache (ao invés da referência original). O mapeamento dos elementos de Coleção continuarão rodando repetitivamente conforme esperado.</para> </listitem> <listitem> <para>Caso a instância da Coleção seja um sub-objeto, por exemplo: dentro de outro POJO, limparemos a referência original com o novo proxy para promover o uso com clareza.</para> </listitem> </itemizedlist> Para obter a referência proxy, os usuários podem usar outro <literal>getObject</literal> para recuperar a referência do proxy e usar a referência para desenvolver as operações POJO."
#. Tag: para
16 years
JBoss Cache SVN: r6970 - enterprise-docs/tags/JBoss_EAP_4_3/Cache_FAQ/de-DE.
by jbosscache-commits@lists.jboss.org
Author: skittoli(a)redhat.com
Date: 2008-10-15 21:37:09 -0400 (Wed, 15 Oct 2008)
New Revision: 6970
Modified:
enterprise-docs/tags/JBoss_EAP_4_3/Cache_FAQ/de-DE/Cache_Frequently_Asked_Questions.po
Log:
updates
Modified: enterprise-docs/tags/JBoss_EAP_4_3/Cache_FAQ/de-DE/Cache_Frequently_Asked_Questions.po
===================================================================
--- enterprise-docs/tags/JBoss_EAP_4_3/Cache_FAQ/de-DE/Cache_Frequently_Asked_Questions.po 2008-10-16 01:00:50 UTC (rev 6969)
+++ enterprise-docs/tags/JBoss_EAP_4_3/Cache_FAQ/de-DE/Cache_Frequently_Asked_Questions.po 2008-10-16 01:37:09 UTC (rev 6970)
@@ -4,7 +4,7 @@
"Project-Id-Version: Cache_Frequently_Asked_Questions\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2008-05-30 03:54+0000\n"
-"PO-Revision-Date: 2008-10-15 06:26+1100\n"
+"PO-Revision-Date: 2008-10-16 09:35+1100\n"
"Last-Translator: \n"
"Language-Team: <en(a)li.org>\n"
"MIME-Version: 1.0\n"
@@ -1341,7 +1341,7 @@
"would result on a ClassCastException. This is because even though the class "
"names are the same, the class definitions are not. The current classloader "
"is different to the one when the classes were originally put."
-msgstr ""
+msgstr "Bei jedem Deployment erstellt JBoss einen neuen Classloader per Deployment Artefakt der obersten Ebene, zum Beispiel ein EAR. Sie sollten weiterhin nicht vergessen, dass eine Klasse in einem Applikationsserver nicht nur durch den Klassennamen, sondern auch durch den Classloader definiert ist. Geht man davon aus, dass das Cache nicht als Teil Ihres Deployment deployt wird, könnten Sie eine Anwendung deployen und zu diesem Deployment gehörende Instanzen von Klassen im Cache platzieren. Falls Sie ein Redeployment durchführen und versuchen eine \"get\"-Operation von zuvor platzierten Daten durchzuführen, so kann dies in einer ClassCastException resultieren. Dies ist der Fall, weil sich die Klassendefinitionen trotz gleicher Klassennamen unterscheiden. Der aktuelle Classloader unterscheidet sich von demjenigen in dem die Klassen ursprünglich platziert wurden."
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1026
@@ -1356,7 +1356,7 @@
"some kind of persistence backing where the data survives, for example using "
"CacheLoaders, or when JBossCache is used as a second level cache in a "
"persistence framework."
-msgstr ""
+msgstr "Durch Aktivierung von “Marshalling” können Sie den Lebenszyklus von Daten im Cache steuern und falls Sie bei Undeployment die Region deaktivieren und deregistrieren, die Sie beim Deployment registriert haben, so führen Sie eine Eviction der Daten im Cache auf lokaler Basis durch. Dies bedeutet, dass die Daten sich beim nächsten Deployment nicht mehr im Cache befinden und so das Problem vermieden wird. Natürlich wird “Marshalling” zur Umgehung dieses Problems nur empfohlen, wenn Sie irgendeine Form von Persistenz-Backing besitzen, bei dem die Daten überleben, etwa bei Verwendung von CacheLoaders oder wenn JBossCache als Cache der zweiten Ebene in einem Persistenz-Framework verwendet wird."
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1035
@@ -2187,6 +2187,8 @@
"Why can't I use <literal>org.jboss.cache.eviction.LRUPolicy</literal> for "
"PojoCache as well?"
msgstr ""
+"Warum kann ich nicht auch <literal>org.jboss.cache.eviction.LRUPolicy</literal> für "
+"PojoCache verwenden?"
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1697
@@ -2196,6 +2198,9 @@
"AopLRUPolicy</literal> ) because AOP has its eviction algorithm, although is "
"LRU but has totally different notion of an \"object\", for example."
msgstr ""
+"Für PojoCache werden Sie <literal>org.jboss.cache.aop.eviction."
+"AopLRUPolicy</literal> ) verwenden müssen, weil AOP einen “Eviction”-Algorithmus besitzt, obwohl "
+"LRU aber etwa einen ganz anderen Begriff von \"Objekt\" besitzt."
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1708
@@ -2203,13 +2208,13 @@
msgid ""
"Does JBoss Cache's implemented LRU eviction policy operates in replication "
"mode?"
-msgstr ""
+msgstr "Operiert JBoss Caches implementierte LRU “Eviction”-Richtlinie im Replikationsmodus?"
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1714
#, no-c-format
msgid "Yes and no. :-)"
-msgstr ""
+msgstr "Ja und nein. :-)"
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1716
@@ -2223,6 +2228,8 @@
"the data in the cache. During this moment, the node content will be "
"propagated and the cache content will be in sync."
msgstr ""
+"Die LRU-Richtlinie läuft nur in lokalem Modus. Das heißt, eine Eviction der Nodes findet nur lokal statt. Dies kann dazu führen, dass Cache-Inhalte temporär nicht synchronisiert werden. Versucht ein Benutzer aber, die gecachten Inhalte eines Nodes abzurufen, bei dem eine Eviction durchgeführt wurde und findet dieser heraus, dass dies Null ist (z.B. liefert <literal>get</literal> "
+"Null), sollten diese von der anderen Datenquelle abgerufen und das Cache erneut mit den Daten aufgefüllt werden. In diesem Moment werden die Node-Inhalte weitergegeben und die Cache-Inhalte sind in sync."
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1727
@@ -2233,7 +2240,7 @@
"your use case, you can set multiple cache instances to have their own "
"eviction policy (which are applied locally) or just have selected instances "
"with eviction policies activated."
-msgstr ""
+msgstr "Sie können jedoch \"Eviction\"-Richtlinien nach wie vor mit auf <literal>REPL_SYNC</literal> oder <literal>REPL_ASYNC</literal> eingestelltem Cache-Modus ausführen. Je nach Ihrem Anwendungsfall können Sie mehrere Cache-Instanzen mit jeweils eigener \"Eviction\"-Richtlinie (die lokal angewendet werden) oder nur ausgewählte Instanzen mit aktivierten \"Eviction\"-Richtlinien besitzen."
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1738
@@ -2242,13 +2249,13 @@
"Also note that, with cache loader option, a locally evicted node can also be "
"persisted to the backend store and a user can retrieve it from the store "
"later on."
-msgstr ""
+msgstr "Beachten Sie auch, dass mit der Cache-Loader-Option ein lokal ausgewiesener Node (d.h. Bei dem eine Eviction stattgefunden hat) auch zum Backend-Speicher hin persistiert werden kann und dass ein Benutzer diesen später aus dem Speicher abrufen kann."
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1747
#, no-c-format
msgid "Does JBoss Cache support <literal>Region</literal> ?"
-msgstr ""
+msgstr "Unterstützt JBoss Cache <literal>Region</literal> ?"
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1754
@@ -2258,6 +2265,8 @@
"eviction policy parameters (e.g., <literal>maxNodes</literal> or "
"<literal>timeToIdleSeconds</literal> )"
msgstr ""
+"Ja. JBoss Cache kennt den Begriff der \"Region\" wo ein Benutzer die Parameter der Eviction-Richtlinien konfigurieren kann (z.B. <literal>maxNodes</literal> oder "
+"<literal>timeToIdleSeconds</literal> )"
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1762
@@ -2270,6 +2279,8 @@
"programmatically now, i.e., everything has to be configured through the xml "
"file."
msgstr ""
+"Eine Region bei JBoss Cache denotiert einen Teil der Baumhierarchie z.B. einen vollständig angegebenen Namen ( <literal>FQN</literal> ). Fzum Beispiel kann ein Benutzer "
+"<literal>/org/jboss</literal> und <literal>/org/foocom</literal> als zwei separate Regionen definieren. Beachten Sie aber, dass Sie die Region jetzt programmatisch definieren können, d.h. Alles muss über die xml-Datei konfiguriert werden."
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1779
@@ -2278,24 +2289,26 @@
"What are the <literal>EvictionPolicyConfig</literal> tag parameters for "
"<literal>org.jboss.cache.eviction.LRUPolicy</literal> ?"
msgstr ""
+"Welches sind die <literal>EvictionPolicyConfig</literal> Tag-Parameter für "
+"<literal>org.jboss.cache.eviction.LRUPolicy</literal> ?"
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1789
#, no-c-format
msgid "They are:"
-msgstr ""
+msgstr "Sie lauten:"
#. Tag: title
#: Cache_Frequently_Asked_Questions.xml:1793
#, no-c-format
msgid "Parameters"
-msgstr ""
+msgstr "Parameter"
#. Tag: entry
#: Cache_Frequently_Asked_Questions.xml:1798
#, no-c-format
msgid "wakeUpIntervalInSeconds"
-msgstr ""
+msgstr "wakeUpIntervalInSeconds"
#. Tag: entry
#: Cache_Frequently_Asked_Questions.xml:1800
@@ -2303,13 +2316,13 @@
msgid ""
"Interval where the clean up thread wakes to process the sitting queue and "
"sweep away the old data."
-msgstr ""
+msgstr "Intervall, in dem der bereinigte Thread erwacht, um den der wartenden Warteschlange zu verarbeiten und die alten Daten zu entfernen."
#. Tag: entry
#: Cache_Frequently_Asked_Questions.xml:1806
#, no-c-format
msgid "region"
-msgstr ""
+msgstr "region"
#. Tag: entry
#: Cache_Frequently_Asked_Questions.xml:1808
@@ -2368,6 +2381,8 @@
"the VM heap size, you can also reduce the <literal>wakeUpIntervaleInSeconds</"
"literal> so the timer thread processes the queue more frequently."
msgstr ""
+"OOM kann vorkommen, wenn die Geschwindigkeit des Cache-Zugriffs die Geschwindigkeit des Timers, der die Eviction-Richtlinien handhabt, überschreitet. Der Handhaber der Eviction-Richtlinien erwacht alle "
+"<literal>wakeUpIntervalInSeconds</literal> Sekunden, um die “Eviction”-Ereigniswarteschlange zu bearbeiten. Und die Größe der Warteschlange ist jetzt bei 20000 festgelegt. Wenn also die Größe der Warteschlange voll ist, wird ein Backlog erstellt und OOM findet statt, falls der Eviction-Timer nicht aufholt. Um dieses Problem anzugehen können Sie – neben Erhöhung des VM-Heap-Size – auch den <literal>wakeUpIntervaleInSeconds</literal> reduzieren, damit der Timer-Thread die Warteschlange häufiger bearbeitet."
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1858
@@ -2405,7 +2420,6 @@
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1884
#, no-c-format
-#, fuzzy
msgid ""
"In conjunction with eviction policies, JBossCache with a CacheLoader allows "
"a user to maintain a bounded cache for a large backend datastore. Frequently "
@@ -2413,13 +2427,7 @@
"data is evicted, in order to provide fast access to frequently accessed "
"data. This is all configured through XML, and the programmer doesn't have to "
"take care of loading and eviction."
-msgstr ""
-"In Verbindung mit den \"Eviction\"-Richtlinien gestattet JBossCache mit einem CacheLoader allows "
-"a user to maintain a bounded cache for a large backend datastore. Frequently "
-"used data is fetched from the datastore into the cache, and the least used "
-"data is evicted, in order to provide fast access to frequently accessed "
-"data. This is all configured through XML, and the programmer doesn't have to "
-"take care of loading and eviction."
+msgstr "In Verbindung mit den \"Eviction\"-Richtlinien gestattet JBossCache mit einem CacheLoader es einem Benutzer ein Cache für einen großen Backend-Datenspeicher zu warten. Häufig verwendete Daten werden vom Datenspeicher in das Cache abgerufen und die am wenigsten verwendeten Daten ausgewiesen, um schnellen Zugriff auf häufig verwendete Daten zu gewährleisten. Das alles wird durch XML konfiguriert und der Programmierer muss sich nicht um das Laden und Eviction zu kümmern."
#. Tag: para
#: Cache_Frequently_Asked_Questions.xml:1893
16 years
JBoss Cache SVN: r6969 - in core/branches/flat/src/main/java/org/jboss/starobrno: lock and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-10-15 21:00:50 -0400 (Wed, 15 Oct 2008)
New Revision: 6969
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/loader/FileCacheLoader.java
core/branches/flat/src/main/java/org/jboss/starobrno/loader/FileCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLock.java
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
Log:
Port FileCacheLoader
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java 2008-10-16 00:50:31 UTC (rev 6968)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java 2008-10-16 01:00:50 UTC (rev 6969)
@@ -118,13 +118,6 @@
V put(Object key, V value) ;
/**
- * Removes the given key and value from the attributes of the given node.
- * Does nothing if the node doesn't exist
- * Returns the removed value.
- */
- V remove(Object key, V value);
-
- /**
* Removes everything from this cache-loader
*/
void clear();
@@ -134,7 +127,7 @@
*
* @param fqn the {@link Fqn} of the node
*/
- void remove(Object key);
+ V remove(Object key);
/**
* Retrieves all entries stored in this cache loader
Added: core/branches/flat/src/main/java/org/jboss/starobrno/loader/FileCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/loader/FileCacheLoader.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/loader/FileCacheLoader.java 2008-10-16 01:00:50 UTC (rev 6969)
@@ -0,0 +1,495 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.loader;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.jcip.annotations.ThreadSafe;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.lock.StripedLock;
+import org.jboss.starobrno.marshall.EntryData;
+import org.jboss.util.stream.MarshalledValueInputStream;
+
+/**
+ * Simple file-based CacheLoader implementation. Nodes are directories, attributes of a node is a file in the directory
+ * <p/>
+ * The FileCacheLoader has some severe limitations which restrict its use in a production
+ * environment, or if used in such an environment, it should be used with due care and sufficient
+ * understanding of these limitations.
+ * <ul>
+ * <li>Due to the way the FileCacheLoader represents a tree structure on disk (directories and files) traversal is inefficient for deep trees.</li>
+ * <li>Usage on shared filesystems like NFS, Windows shares, etc. should be avoided as these do not implement proper file locking and can cause data corruption.</li>
+ * <li>Usage with an isolation level of NONE can cause corrupt writes as multiple threads attempt to write to the same file.</li>
+ * <li>File systems are inherently not transactional, so when attempting to use your cache in a transactional context, failures when writing to the file (which happens during the commit phase) cannot be recovered.</li>
+ * </ul>
+ * <p/>
+ * As a rule of thumb, it is recommended that the FileCacheLoader not be used in a highly concurrent,
+ * transactional or stressful environment, and its use is restricted to testing.
+ * <p/>
+ * In terms of concurrency, file systems are notoriously inconsistent in their implementations of concurrent locks. To get around
+ * this and to meet the <b>thread safety</b> contracts set out in {@link CacheLoader}, this implementation uses a {@link org.jboss.cache.lock.StripedLock}
+ *
+ * @author Bela Ban
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @version $Id: FileCacheLoader.java 6885 2008-10-08 16:28:04Z manik.surtani(a)jboss.com $
+ */
+@ThreadSafe
+public class FileCacheLoader<K,V> extends AbstractCacheLoader<K,V>
+{
+ File root = null;
+ String rootPath = null;
+ Log log = LogFactory.getLog(getClass());
+
+ protected final StripedLock lock = new StripedLock();
+
+ private FileCacheLoaderConfig config;
+
+ /**
+ * For full path, check '*' '<' '>' '|' '"' '?' Regex: [\*<>|"?]
+ */
+ public static final Pattern PATH_PATTERN = Pattern.compile("[\\*<>|\"?]");
+
+ /**
+ * For fqn, check '*' '<' '>' '|' '"' '?' and also '\' '/' and ':'
+ */
+ public static final Pattern KEY_PATTERN = Pattern.compile("[\\\\\\/:*<>|\"?]");
+ private static boolean isOldWindows;
+
+ static
+ {
+ float osVersion = -1;
+ try
+ {
+ osVersion = Float.parseFloat(System.getProperty("os.version").trim());
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ // 4.x is windows NT/2000 and 5.x is XP.
+ isOldWindows = System.getProperty("os.name").toLowerCase().startsWith("windows") && osVersion < 4;
+ }
+
+ public void setConfig(IndividualCacheLoaderConfig base)
+ {
+ if (base instanceof FileCacheLoaderConfig)
+ {
+ this.config = (FileCacheLoaderConfig) base;
+ }
+ else if (base != null)
+ {
+ this.config = new FileCacheLoaderConfig(base);
+ }
+
+ String location = this.config != null ? this.config.getLocation() : null;
+ if (location != null && location.length() > 0)
+ {
+ root = new File(location);
+ rootPath = root.getAbsolutePath() + File.separator;
+ }
+ }
+
+ public IndividualCacheLoaderConfig getConfig()
+ {
+ return config;
+ }
+
+ @Override
+ public void create()
+ {
+ if (root == null)
+ {
+ String tmpLocation = System.getProperty("java.io.tmpdir", "C:\\tmp");
+ root = new File(tmpLocation);
+ rootPath = root.getAbsolutePath() + File.separator;
+ }
+ if (!root.exists())
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Creating cache loader location " + root);
+ }
+
+ if (config.isCheckCharacterPortability())
+ {
+ /* Before creating the root, check whether the path is character portable. Anything that comes after is part
+ of the fqn which is inspected later. */
+ isCharacterPortableLocation(root.getAbsolutePath());
+ }
+
+ boolean created = root.mkdirs();
+ if (!created)
+ {
+ throw new CacheException("Unable to create cache loader location " + root);
+ }
+ }
+
+ if (!root.isDirectory())
+ {
+ throw new CacheException("Cache loader location [" + root + "] is not a directory!");
+ }
+ }
+
+ public V get(Object key)
+ {
+ lock(key);
+ try
+ {
+ try
+ {
+ return loadValue(key);
+ }
+ catch (Exception e)
+ {
+ throw new CacheException(e);
+ }
+ }
+ finally
+ {
+ unlock(key);
+ }
+ }
+
+ public boolean exists(Object key)
+ {
+ lock(key);
+ try
+ {
+ return getFile(key, false).exists();
+ }
+ catch (IOException e)
+ {
+ throw new CacheException(e);
+ }
+ finally
+ {
+ unlock(key);
+ }
+ }
+
+ public V put(Object key, V value)
+ {
+ lock(key);
+ try
+ {
+ V retval;
+ try
+ {
+ retval = loadValue(key);
+ storeValue(key, value);
+ return retval;
+ }
+ catch (Exception e)
+ {
+ throw new CacheException(e);
+ }
+ }
+ finally
+ {
+ unlock(key);
+ }
+ }
+
+ public V remove(Object key)
+ {
+ lock(key);
+ try
+ {
+ V retval;
+ try
+ {
+ File file = getFile(key, false);
+ if (! file.exists())
+ return null;
+
+ retval = loadValue(key);
+ file.delete();
+ return retval;
+ }
+ catch (Exception e)
+ {
+ throw new CacheException(e);
+ }
+ }
+ finally
+ {
+ unlock(key);
+ }
+ }
+
+ private void unlock(Object key)
+ {
+ lock.releaseLock(key.toString());
+ }
+
+ private void lock(Object key)
+ {
+ lock.acquireLock(key.toString(), true);
+ }
+
+ private File getDirectory(Object key, boolean create) throws IOException
+ {
+ File f = new File(getFullPath(key));
+ if (!f.exists())
+ {
+ if (create)
+ {
+ boolean make = f.mkdirs();
+ if (!make)
+ throw new IOException("Unable to mkdirs " + f);
+ }
+ }
+ return f;
+ }
+
+ private String getFullPath(Object key)
+ {
+ return rootPath;
+ }
+
+ private void safeClose(Closeable closeable)
+ {
+ if (closeable == null)
+ return;
+
+ try
+ {
+ closeable.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+
+ private V loadValue(Object key) throws Exception
+ {
+ File child = getFile(key, false);
+ if (!child.exists())
+ return null;
+
+ return loadValue(child);
+ }
+
+ private V loadValue(File file) throws Exception
+ {
+ FileInputStream fileIn = null;
+ ObjectInputStream input = null;
+
+ try
+ {
+ fileIn = new FileInputStream(file);
+ input = new MarshalledValueInputStream(fileIn);
+ return (V) getMarshaller().objectFromObjectStream(input);
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ return null;
+ }
+ finally
+ {
+ safeClose(input);
+ safeClose(fileIn);
+ }
+ }
+
+ private EntryData<K, V> loadEntry(File file) throws Exception
+ {
+ FileInputStream fileIn = null;
+ ObjectInputStream input = null;
+
+ try
+ {
+ fileIn = new FileInputStream(file);
+ input = new MarshalledValueInputStream(fileIn);
+ V value = (V) getMarshaller().objectFromObjectStream(input);
+ K key = (K) getMarshaller().objectFromObjectStream(input);
+ return new EntryData<K,V>(key, value);
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ return null;
+ }
+ finally
+ {
+ safeClose(input);
+ safeClose(fileIn);
+ }
+ }
+
+ private File getFile(Object key, boolean create) throws IOException
+ {
+ File directory = getDirectory(key, create);
+ File child = new File(directory, key.toString());
+ if (create && !child.exists())
+ {
+ if (config.isCheckCharacterPortability())
+ {
+ /* Check whether the entire file path (root + fqn + data file name), is length portable */
+ isLengthPortablePath(child.getAbsolutePath());
+ /* Check whether the fqn tree we're trying to store could contain non portable characters */
+ isCharacterPortableKey(key);
+ }
+
+ if (!child.createNewFile())
+ {
+ throw new IOException("Unable to create file: " + child);
+ }
+ }
+
+ return child;
+ }
+
+ protected void storeValue(Object key, Object value) throws Exception
+ {
+ File child = getFile(key, true);
+
+ FileOutputStream fileOut = null;
+ ObjectOutputStream output = null;
+ try
+ {
+ fileOut = new FileOutputStream(child);
+ output = new ObjectOutputStream(fileOut);
+ getMarshaller().objectToObjectStream(value, output);
+ getMarshaller().objectToObjectStream(key, output); // For getAllEntries
+ }
+ finally
+ {
+ safeClose(output);
+ safeClose(fileOut);
+ }
+ }
+
+ protected boolean isCharacterPortableLocation(String fileAbsolutePath)
+ {
+ Matcher matcher = PATH_PATTERN.matcher(fileAbsolutePath);
+ if (matcher.find())
+ {
+ log.warn("Cache loader location ( " + fileAbsolutePath + " ) contains one of these characters: '*' '<' '>' '|' '\"' '?'");
+ log.warn("Directories containing these characters are illegal in some operative systems and could lead to portability issues");
+ return false;
+ }
+
+ return true;
+ }
+
+ protected boolean isCharacterPortableKey(Object key)
+ {
+ // getFullPath converts Object to String via toString(), so we do too
+ Matcher matcher = KEY_PATTERN.matcher(key.toString());
+ if (matcher.find())
+ {
+ log.warn("The key.toString() contains one of these characters: '*' '<' '>' '|' '\"' '?' '\\' '/' ':' ");
+ log.warn("Directories containing these characters are illegal in some operating systems and could lead to portability issues");
+ return false;
+ }
+
+ return true;
+ }
+
+ protected boolean isLengthPortablePath(String absoluteFqnPath)
+ {
+
+ if (isOldWindows && absoluteFqnPath.length() > 255)
+ {
+ log.warn("The full absolute path to the fqn that you are trying to store is bigger than 255 characters, this could lead to problems on certain Windows systems: " + absoluteFqnPath);
+ return false;
+ }
+
+ return true;
+ }
+
+ public void clear()
+ {
+ File directory = new File(rootPath);
+ if (! directory.exists())
+ return;
+
+ File[] files = directory.listFiles();
+ if (files != null)
+ {
+ for (File file : files)
+ {
+ try
+ {
+ lock(file.getName());
+ if (file.exists())
+ file.delete();
+ }
+ finally
+ {
+ unlock(file.getName());
+ }
+ }
+ }
+ }
+
+ public List<EntryData<K, V>> getAllEntries()
+ {
+ List<EntryData<K,V>> entries = new LinkedList<EntryData<K,V>>();
+ File directory = new File(rootPath);
+ if (! directory.exists())
+ return entries;
+
+ File[] files = directory.listFiles();
+ if (files != null)
+ {
+ for (File file : files)
+ {
+ try
+ {
+ lock(file.getName());
+ if (file.exists())
+ {
+ EntryData<K,V> entry = loadEntry(file);
+ if (entry != null)
+ entries.add(entry);
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ finally
+ {
+ unlock(file.getName());
+ }
+ }
+ }
+
+ return entries;
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/loader/FileCacheLoader.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/loader/FileCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/loader/FileCacheLoaderConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/loader/FileCacheLoaderConfig.java 2008-10-16 01:00:50 UTC (rev 6969)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.loader;
+
+import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.Dynamic;
+
+import java.util.Properties;
+
+public class FileCacheLoaderConfig extends IndividualCacheLoaderConfig
+{
+ private static final long serialVersionUID = 4626734068542420865L;
+
+ private String location;
+ @Dynamic
+ private boolean checkCharacterPortability = true;
+
+ public FileCacheLoaderConfig()
+ {
+ setClassName(FileCacheLoader.class.getName());
+ }
+
+ /**
+ * For use by {@link FileCacheLoader}.
+ *
+ * @param base generic config object created by XML parsing.
+ */
+ FileCacheLoaderConfig(IndividualCacheLoaderConfig base)
+ {
+ setClassName(FileCacheLoader.class.getName());
+ populateFromBaseConfig(base);
+ }
+
+ public String getLocation()
+ {
+ return location;
+ }
+
+ public void setLocation(String location)
+ {
+ testImmutability("location");
+ this.location = location;
+ }
+
+ public boolean isCheckCharacterPortability()
+ {
+ return checkCharacterPortability;
+ }
+
+ public void setCheckCharacterPortability(boolean checkCharacterPortability)
+ {
+ testImmutability("check.character.portability");
+ this.checkCharacterPortability = checkCharacterPortability;
+ }
+
+ @Override
+ public void setProperties(Properties props)
+ {
+ super.setProperties(props);
+
+ if (props != null)
+ {
+ setLocation(props.getProperty("location"));
+ String prop = props.getProperty("check.character.portability");
+ setCheckCharacterPortability((prop == null || Boolean.valueOf(prop)));
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof FileCacheLoaderConfig && equalsExcludingProperties(obj))
+ {
+ return Util.safeEquals(location, ((FileCacheLoaderConfig) obj).location);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return 31 * hashCodeExcludingProperties() + (location == null ? 0 : location.hashCode());
+ }
+
+ @Override
+ public FileCacheLoaderConfig clone() throws CloneNotSupportedException
+ {
+ return (FileCacheLoaderConfig) super.clone();
+ }
+
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLock.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLock.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLock.java 2008-10-16 01:00:50 UTC (rev 6969)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.lock;
+
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.cache.Fqn;
+
+import java.util.List;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * A simple implementation of lock striping, using Fqns as the keys to lock on, primarily used to help make
+ * {@link org.jboss.cache.loader.CacheLoader} implemtations thread safe.
+ * <p/>
+ * Backed by a set of {@link java.util.concurrent.locks.ReentrantReadWriteLock} instances, and using the {@link org.jboss.cache.Fqn}
+ * hashcodes to determine buckets.
+ * <p/>
+ * Since buckets are used, it doesn't matter that the Fqn in question is not removed from the lock map when no longer in
+ * use, since the Fqn is not referenced in this class. Rather, the hash code is used.
+ * <p/>
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+@ThreadSafe
+public class StripedLock
+{
+ private static final int DEFAULT_CONCURRENCY = 20;
+ private final int lockSegmentMask;
+ private final int lockSegmentShift;
+
+ final ReentrantReadWriteLock[] sharedLocks;
+
+ /**
+ * This constructor just calls {@link #StripedLock(int)} with a default concurrency value of 20.
+ */
+ public StripedLock()
+ {
+ this(DEFAULT_CONCURRENCY);
+ }
+
+ /**
+ * Creates a new StripedLock which uses a certain number of shared locks across all elements that need to be locked.
+ *
+ * @param concurrency number of threads expected to use this class concurrently.
+ */
+ public StripedLock(int concurrency)
+ {
+ int tempLockSegShift = 0;
+ int numLocks = 1;
+ while (numLocks < concurrency)
+ {
+ ++tempLockSegShift;
+ numLocks <<= 1;
+ }
+ lockSegmentShift = 32 - tempLockSegShift;
+ lockSegmentMask = numLocks - 1;
+
+ sharedLocks = new ReentrantReadWriteLock[numLocks];
+
+ for (int i = 0; i < numLocks; i++) sharedLocks[i] = new ReentrantReadWriteLock();
+ }
+
+ /**
+ * Blocks until a lock is acquired.
+ *
+ * @param fqn the Fqn to lock on
+ * @param exclusive if true, a write (exclusive) lock is attempted, otherwise a read (shared) lock is used.
+ */
+ public void acquireLock(Object key, boolean exclusive)
+ {
+ ReentrantReadWriteLock lock = getLock(key);
+
+ if (exclusive)
+ {
+ lock.writeLock().lock();
+ }
+ else
+ {
+ lock.readLock().lock();
+ }
+ }
+
+ /**
+ * Releases a lock the caller may be holding. This method is idempotent.
+ *
+ * @param fqn the Fqn to release
+ */
+ public void releaseLock(Object key)
+ {
+ ReentrantReadWriteLock lock = getLock(key);
+ if (lock.isWriteLockedByCurrentThread())
+ {
+ lock.writeLock().unlock();
+ }
+ else
+ {
+ lock.readLock().unlock();
+ }
+ }
+
+ final ReentrantReadWriteLock getLock(Object o)
+ {
+ return sharedLocks[hashToIndex(o)];
+ }
+
+ final int hashToIndex(Object o)
+ {
+ return (hash(o) >>> lockSegmentShift) & lockSegmentMask;
+ }
+
+ /**
+ * Returns a hash code for non-null Object x.
+ * Uses the same hash code spreader as most other java.util hash tables, except that this uses the string representation
+ * of the object passed in.
+ *
+ * @param x the object serving as a key
+ * @return the hash code
+ */
+ final int hash(Object x)
+ {
+ int h = x.hashCode();
+ h ^= (h >>> 20) ^ (h >>> 12);
+ return h ^ (h >>> 7) ^ (h >>> 4);
+ }
+
+ /**
+ * Releases locks on all fqns passed in. Makes multiple calls to {@link #releaseLock(org.jboss.cache.Fqn)}. This method is idempotent.
+ *
+ * @param fqns list of fqns
+ * @see #releaseLock(org.jboss.cache.Fqn)
+ */
+ public void releaseAllLocks(List<Object> keys)
+ {
+ for (Object k : keys) releaseLock(k);
+ }
+
+ /**
+ * Acquires locks on all fqns passed in. Makes multiple calls to {@link #acquireLock(org.jboss.cache.Fqn,boolean)}
+ *
+ * @param fqns list of fqns
+ * @param exclusive whether locks are exclusive.
+ * @see #acquireLock(org.jboss.cache.Fqn,boolean)
+ */
+ public void acquireAllLocks(List<Object> keys, boolean exclusive)
+ {
+ for (Object k : keys) acquireLock(k, exclusive);
+ }
+}
16 years
JBoss Cache SVN: r6967 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-15 18:07:39 -0400 (Wed, 15 Oct 2008)
New Revision: 6967
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheStatus.java
Log:
[JBCACHE-1429] Don't WARN on reentrant xxxAllowed() checks
Modified: core/trunk/src/main/java/org/jboss/cache/CacheStatus.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheStatus.java 2008-10-15 21:56:51 UTC (rev 6966)
+++ core/trunk/src/main/java/org/jboss/cache/CacheStatus.java 2008-10-15 22:07:39 UTC (rev 6967)
@@ -149,13 +149,13 @@
{
case INSTANTIATED:
case CREATED:
+ case STOPPING:
case STOPPED:
case DESTROYED:
log.debug("Ignoring call to stop() as current state is " + this);
return false;
case CREATING:
case STARTING:
- case STOPPING:
case DESTROYING:
log.warn("Ignoring call to stop() as current state is " + this);
return false;
@@ -172,14 +172,14 @@
switch (this)
{
case INSTANTIATED:
+ case DESTROYING:
case DESTROYED:
log.debug("Ignoring call to destroy() as current state is " + this);
return false;
case CREATING:
case STARTING:
case STOPPING:
- case DESTROYING:
- log.warn("Ignoring call to destroy() as current state iswhile cache is " + this);
+ log.warn("Ignoring call to destroy() as current state is " + this);
return false;
case STARTED:
// stop first
16 years
JBoss Cache SVN: r6966 - core/branches/2.2.X/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-15 17:56:51 -0400 (Wed, 15 Oct 2008)
New Revision: 6966
Modified:
core/branches/2.2.X/src/main/java/org/jboss/cache/CacheStatus.java
Log:
[JBCACHE-1429] Don't WARN on reentrant xxxAllowed() checks
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/CacheStatus.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/CacheStatus.java 2008-10-15 20:48:28 UTC (rev 6965)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/CacheStatus.java 2008-10-15 21:56:51 UTC (rev 6966)
@@ -162,13 +162,13 @@
{
case INSTANTIATED:
case CREATED:
+ case STOPPING:
case STOPPED:
case DESTROYED:
log.debug("Ignoring call to stop() as current state is " + this);
return false;
case CREATING:
case STARTING:
- case STOPPING:
case DESTROYING:
log.warn("Ignoring call to stop() as current state is " + this);
return false;
@@ -185,14 +185,14 @@
switch (this)
{
case INSTANTIATED:
+ case DESTROYING:
case DESTROYED:
log.debug("Ignoring call to destroy() as current state is " + this);
return false;
case CREATING:
case STARTING:
case STOPPING:
- case DESTROYING:
- log.warn("Ignoring call to destroy() as current state iswhile cache is " + this);
+ log.warn("Ignoring call to destroy() as current state is " + this);
return false;
case STARTED:
// stop first
16 years
JBoss Cache SVN: r6965 - in core/branches/flat/src/main/java/org/jboss: cache/loader and 10 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-15 16:48:28 -0400 (Wed, 15 Oct 2008)
New Revision: 6965
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/VersionAwareMarshaller.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/Util.java
Removed:
core/branches/flat/src/main/java/org/jboss/cache/util/Util.java
Modified:
core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/BuddyReplicationConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/CustomInterceptorsElementParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/CacheMarshallerStarobrno.java
Log:
replication is versioned now
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.EvictionAlgorithmConfig;
import org.jboss.starobrno.config.EvictionRegionConfig;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -27,7 +27,7 @@
import org.jboss.cache.Modification;
import org.jboss.starobrno.io.ByteBuffer;
import org.jboss.cache.lock.StripedLock;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.CacheLoaderConfig;
import java.io.IOException;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.starobrno.config.Dynamic;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader.bdbje;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader.jdbm;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -26,7 +26,7 @@
import org.jboss.cache.Fqn;
import org.jboss.starobrno.io.ByteBuffer;
import org.jboss.starobrno.io.ExposedByteArrayOutputStream;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/util/Util.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/Util.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/Util.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -1,188 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.util;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * General utility methods used throughout the JBC code base.
- *
- * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public final class Util
-{
- /**
- * Loads the specified class using this class's classloader, or, if it is <code>null</code>
- * (i.e. this class was loaded by the bootstrap classloader), the system classloader.
- * <p/>
- * If loadtime instrumentation via GenerateInstrumentedClassLoader is used, this
- * class may be loaded by the bootstrap classloader.
- * </p>
- *
- * @param classname name of the class to load
- * @return the class
- * @throws ClassNotFoundException
- */
- public static Class loadClass(String classname) throws ClassNotFoundException
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null)
- cl = ClassLoader.getSystemClassLoader();
- return cl.loadClass(classname);
- }
-
- @SuppressWarnings("unchecked")
- public static <T> T getInstance(Class<T> clazz) throws Exception
- {
- // first look for a getInstance() constructor
- T instance;
- try
- {
- Method factoryMethod = clazz.getMethod("getInstance", new Class[]{});
- instance = (T) factoryMethod.invoke(null);
- }
- catch (Exception e)
- {
- // no factory method or factory method failed. Try a constructor.
- instance = clazz.newInstance();
- }
- return instance;
- }
-
- @SuppressWarnings("unchecked")
- public static Object getInstance(String classname) throws Exception
- {
- if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
- Class clazz = loadClass(classname);
- return getInstance(clazz);
- }
-
- /**
- * Prevent instantiation
- */
- private Util()
- {
- }
-
- /**
- * Calculates the diffs between data maps passed in to {@link org.jboss.cache.notifications.event.NodeModifiedEvent#getData()}
- * before and after modification. This only makes sense if the modification type is {@link org.jboss.cache.notifications.event.NodeModifiedEvent.ModificationType#PUT_MAP}.
- * Refer to {@link org.jboss.cache.notifications.event.NodeModifiedEvent} and {@link org.jboss.cache.notifications.annotation.NodeModified}.
- *
- * @param pre map of data before the node was modified
- * @param post Map of data after the node was modified
- * @return MapModifications containing the differences.
- */
- public static MapModifications diffNodeData(Map<Object, Object> pre, Map<Object, Object> post)
- {
- MapModifications mods = new MapModifications();
-
- // let's start with what's been added and modified.
- for (Map.Entry me : post.entrySet())
- {
- Object key = me.getKey();
- Object value = me.getValue();
- if (pre.containsKey(key))
- {
- if (!value.equals(pre.get(key)))
- {
- mods.modifiedEntries.put(key, value);
- }
- }
- else
- {
- mods.addedEntries.put(key, value);
- }
- }
-
- // now the removed entries.
- for (Map.Entry me : pre.entrySet())
- {
- Object key = me.getKey();
- if (!post.containsKey(key))
- {
- mods.removedEntries.put(key, me.getValue());
- }
- }
-
- return mods;
- }
-
- /**
- * Null-safe equality test.
- *
- * @param a first object to compare
- * @param b second object to compare
- * @return true if the objects are equals or both null, false otherwise.
- */
- public static boolean safeEquals(Object a, Object b)
- {
- return (a == b) || (a != null && a.equals(b));
- }
-
- /**
- * Static inner class that holds 3 maps - for data added, removed and modified.
- */
- public static class MapModifications
- {
- public final Map<Object, Object> addedEntries = new HashMap<Object, Object>();
- public final Map<Object, Object> removedEntries = new HashMap<Object, Object>();
- public final Map<Object, Object> modifiedEntries = new HashMap<Object, Object>();
-
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- MapModifications that = (MapModifications) o;
-
- if (addedEntries != null ? !addedEntries.equals(that.addedEntries) : that.addedEntries != null) return false;
- if (modifiedEntries != null ? !modifiedEntries.equals(that.modifiedEntries) : that.modifiedEntries != null)
- return false;
- if (removedEntries != null ? !removedEntries.equals(that.removedEntries) : that.removedEntries != null)
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result;
- result = (addedEntries != null ? addedEntries.hashCode() : 0);
- result = 31 * result + (removedEntries != null ? removedEntries.hashCode() : 0);
- result = 31 * result + (modifiedEntries != null ? modifiedEntries.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString()
- {
- return "Added Entries " + addedEntries + " Removeed Entries " + removedEntries + " Modified Entries " + modifiedEntries;
- }
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -22,16 +22,16 @@
package org.jboss.starobrno.commands;
import org.jboss.starobrno.CacheException;
-import org.jboss.starobrno.interceptors.InterceptorChain;
import org.jboss.starobrno.commands.read.GetKeyValueCommand;
import org.jboss.starobrno.commands.read.SizeCommand;
+import org.jboss.starobrno.commands.remote.ReplicateCommand;
import org.jboss.starobrno.commands.tx.CommitCommand;
import org.jboss.starobrno.commands.tx.PrepareCommand;
import org.jboss.starobrno.commands.tx.RollbackCommand;
import org.jboss.starobrno.commands.write.*;
-import org.jboss.starobrno.commands.remote.ReplicateCommand;
import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.interceptors.InterceptorChain;
import org.jboss.starobrno.notifications.Notifier;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jgroups.Address;
@@ -49,7 +49,7 @@
private InterceptorChain interceptorChain;
@Inject
- private void setupDependencies(DataContainer container, Notifier notifier, InterceptorChain interceptorChain)
+ public void setupDependencies(DataContainer container, Notifier notifier, InterceptorChain interceptorChain)
{
this.dataContainer = container;
this.notifier = notifier;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/BuddyReplicationConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/BuddyReplicationConfig.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/BuddyReplicationConfig.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -22,7 +22,7 @@
package org.jboss.starobrno.config;
import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheLoaderConfig.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheLoaderConfig.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -23,7 +23,7 @@
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.SingletonStoreCacheLoader;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import java.util.ArrayList;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import java.lang.reflect.Method;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -23,7 +23,7 @@
import org.jboss.cache.RPCManager;
import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jgroups.Channel;
import org.jgroups.ChannelFactory;
import org.jgroups.util.ThreadFactory;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/CustomInterceptorsElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/CustomInterceptorsElementParser.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/CustomInterceptorsElementParser.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -22,7 +22,7 @@
package org.jboss.starobrno.config.parsing.element;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.CustomInterceptorConfig;
import org.jboss.starobrno.config.parsing.ParsedAttributes;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -21,7 +21,7 @@
*/
package org.jboss.starobrno.config.parsing.element;
-import org.jboss.cache.util.Util;
+import org.jboss.starobrno.util.Util;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.EvictionAlgorithmConfig;
import org.jboss.starobrno.config.EvictionConfig;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -35,6 +35,7 @@
import org.jboss.starobrno.remoting.ChannelMessageListener;
import org.jboss.starobrno.marshall.ExtendedMarshaller;
import org.jboss.starobrno.marshall.CacheMarshallerStarobrno;
+import org.jboss.starobrno.marshall.VersionAwareMarshaller;
import org.jboss.starobrno.RPCManager;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.invocation.CacheInvocationDelegate;
@@ -65,7 +66,7 @@
Class componentImpl;
if (componentType.equals(ExtendedMarshaller.class))
{
- componentImpl = CacheMarshallerStarobrno.class;
+ componentImpl = VersionAwareMarshaller.class;
}
else
if (componentType.equals(RPCManager.class))
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/marshall/CacheMarshallerStarobrno.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/marshall/CacheMarshallerStarobrno.java 2008-10-15 20:24:43 UTC (rev 6964)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/marshall/CacheMarshallerStarobrno.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -100,11 +100,11 @@
protected ClassLoader defaultClassLoader;
protected boolean useRefs = false;
- @Inject
- void injectDependencies(Configuration configuration, ClassLoader defaultClassLoader)
+ public void init(Configuration configuration, ClassLoader defaultClassLoader, CommandsFactory commandsFactory)
{
this.defaultClassLoader = defaultClassLoader;
this.configuration = configuration;
+ this.commandsFactory = commandsFactory;
}
protected void initLogger()
@@ -124,13 +124,6 @@
protected CommandsFactory commandsFactory;
-
- @Inject
- public void injectCommandsFactory(CommandsFactory commandsFactory)
- {
- this.commandsFactory = commandsFactory;
- }
-
protected void marshallObject(Object o, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception
{
if (o != null && o.getClass().isArray() && isKnownType(o.getClass().getComponentType()))
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/marshall/VersionAwareMarshaller.java (from rev 6959, core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/marshall/VersionAwareMarshaller.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/marshall/VersionAwareMarshaller.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.marshall;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.io.ByteBuffer;
+import org.jboss.starobrno.io.ExposedByteArrayOutputStream;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.commands.CommandsFactory;
+import org.jboss.util.stream.MarshalledValueInputStream;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.StringTokenizer;
+
+/**
+ * A delegate to various other marshallers like {@link org.jboss.cache.marshall.CacheMarshaller200}.
+ * This delegating marshaller adds versioning information to the stream when marshalling objects and
+ * is able to pick the appropriate marshaller to delegate to based on the versioning information when
+ * unmarshalling objects.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
+ */
+public class VersionAwareMarshaller implements ExtendedMarshaller
+{
+ private static final Log log = LogFactory.getLog(VersionAwareMarshaller.class);
+ private boolean trace = log.isTraceEnabled();
+
+ private static final int VERSION_400 = 40;
+ private static final int CUSTOM_MARSHALLER = 999;
+
+ private CacheMarshallerStarobrno defaultMarshaller;
+
+ ClassLoader defaultClassLoader;
+ private Configuration configuration;
+
+ @Inject
+ public void init(ClassLoader loader, Configuration configuration, CommandsFactory factory)
+ {
+ defaultMarshaller = new CacheMarshallerStarobrno();
+ defaultMarshaller.init(configuration, loader, factory);
+ }
+
+ protected int getCustomMarshallerVersionInt()
+ {
+ return CUSTOM_MARSHALLER;
+ }
+
+ public ByteBuffer objectToBuffer(Object obj) throws Exception
+ {
+ ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
+ ObjectOutputStream out = new ObjectOutputStream(baos);
+
+ out.writeShort(VERSION_400);
+ if (trace) log.trace("Wrote version " + VERSION_400);
+
+ //now marshall the contents of the object
+ defaultMarshaller.objectToObjectStream(obj, out);
+ out.close();
+
+ // and return bytes.
+ return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
+ }
+
+ public Object objectFromByteBuffer(byte[] bytes, int offset, int len) throws Exception
+ {
+ int versionId;
+ ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes, offset, len));
+ try
+ {
+ versionId = in.readShort();
+ if (trace) log.trace("Read version " + versionId);
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to read version id from first two bytes of stream, barfing.");
+ throw e;
+ }
+ return defaultMarshaller.objectFromObjectStream(in);
+ }
+
+ public Object objectFromStream(InputStream is) throws Exception
+ {
+ short versionId;
+ ObjectInputStream in = new MarshalledValueInputStream(is);
+ try
+ {
+ versionId = in.readShort();
+ if (trace) log.trace("Read version " + versionId);
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to read version id from first two bytes of stream, barfing.");
+ throw e;
+ }
+ return defaultMarshaller.objectFromObjectStream(in);
+ }
+
+ public void objectToObjectStream(Object obj, ObjectOutputStream out) throws Exception
+ {
+ out.writeShort(VERSION_400);
+ if (trace) log.trace("Wrote version " + VERSION_400);
+ defaultMarshaller.objectToObjectStream(obj, out);
+ }
+
+ public Object objectFromObjectStream(ObjectInputStream in) throws Exception
+ {
+ int versionId;
+ try
+ {
+ versionId = in.readShort();
+ if (trace) log.trace("Read version " + versionId);
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to read version id from first two bytes of stream, barfing.");
+ throw e;
+ }
+ return defaultMarshaller.objectFromObjectStream(in);
+ }
+
+ public byte[] objectToByteBuffer(Object obj) throws Exception
+ {
+ return defaultMarshaller.objectToByteBuffer(obj);
+ }
+
+ public Object objectFromByteBuffer(byte[] buf) throws Exception
+ {
+ return defaultMarshaller.objectFromByteBuffer(buf);
+ }
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/marshall/VersionAwareMarshaller.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/Util.java (from rev 6959, core/branches/flat/src/main/java/org/jboss/cache/util/Util.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/Util.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/Util.java 2008-10-15 20:48:28 UTC (rev 6965)
@@ -0,0 +1,188 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.util;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * General utility methods used throughout the JBC code base.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public final class Util
+{
+ /**
+ * Loads the specified class using this class's classloader, or, if it is <code>null</code>
+ * (i.e. this class was loaded by the bootstrap classloader), the system classloader.
+ * <p/>
+ * If loadtime instrumentation via GenerateInstrumentedClassLoader is used, this
+ * class may be loaded by the bootstrap classloader.
+ * </p>
+ *
+ * @param classname name of the class to load
+ * @return the class
+ * @throws ClassNotFoundException
+ */
+ public static Class loadClass(String classname) throws ClassNotFoundException
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null)
+ cl = ClassLoader.getSystemClassLoader();
+ return cl.loadClass(classname);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T> T getInstance(Class<T> clazz) throws Exception
+ {
+ // first look for a getInstance() constructor
+ T instance;
+ try
+ {
+ Method factoryMethod = clazz.getMethod("getInstance", new Class[]{});
+ instance = (T) factoryMethod.invoke(null);
+ }
+ catch (Exception e)
+ {
+ // no factory method or factory method failed. Try a constructor.
+ instance = clazz.newInstance();
+ }
+ return instance;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Object getInstance(String classname) throws Exception
+ {
+ if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
+ Class clazz = loadClass(classname);
+ return getInstance(clazz);
+ }
+
+ /**
+ * Prevent instantiation
+ */
+ private Util()
+ {
+ }
+
+ /**
+ * Calculates the diffs between data maps passed in to {@link org.jboss.cache.notifications.event.NodeModifiedEvent#getData()}
+ * before and after modification. This only makes sense if the modification type is {@link org.jboss.cache.notifications.event.NodeModifiedEvent.ModificationType#PUT_MAP}.
+ * Refer to {@link org.jboss.cache.notifications.event.NodeModifiedEvent} and {@link org.jboss.cache.notifications.annotation.NodeModified}.
+ *
+ * @param pre map of data before the node was modified
+ * @param post Map of data after the node was modified
+ * @return MapModifications containing the differences.
+ */
+ public static MapModifications diffNodeData(Map<Object, Object> pre, Map<Object, Object> post)
+ {
+ MapModifications mods = new MapModifications();
+
+ // let's start with what's been added and modified.
+ for (Map.Entry me : post.entrySet())
+ {
+ Object key = me.getKey();
+ Object value = me.getValue();
+ if (pre.containsKey(key))
+ {
+ if (!value.equals(pre.get(key)))
+ {
+ mods.modifiedEntries.put(key, value);
+ }
+ }
+ else
+ {
+ mods.addedEntries.put(key, value);
+ }
+ }
+
+ // now the removed entries.
+ for (Map.Entry me : pre.entrySet())
+ {
+ Object key = me.getKey();
+ if (!post.containsKey(key))
+ {
+ mods.removedEntries.put(key, me.getValue());
+ }
+ }
+
+ return mods;
+ }
+
+ /**
+ * Null-safe equality test.
+ *
+ * @param a first object to compare
+ * @param b second object to compare
+ * @return true if the objects are equals or both null, false otherwise.
+ */
+ public static boolean safeEquals(Object a, Object b)
+ {
+ return (a == b) || (a != null && a.equals(b));
+ }
+
+ /**
+ * Static inner class that holds 3 maps - for data added, removed and modified.
+ */
+ public static class MapModifications
+ {
+ public final Map<Object, Object> addedEntries = new HashMap<Object, Object>();
+ public final Map<Object, Object> removedEntries = new HashMap<Object, Object>();
+ public final Map<Object, Object> modifiedEntries = new HashMap<Object, Object>();
+
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ MapModifications that = (MapModifications) o;
+
+ if (addedEntries != null ? !addedEntries.equals(that.addedEntries) : that.addedEntries != null) return false;
+ if (modifiedEntries != null ? !modifiedEntries.equals(that.modifiedEntries) : that.modifiedEntries != null)
+ return false;
+ if (removedEntries != null ? !removedEntries.equals(that.removedEntries) : that.removedEntries != null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result;
+ result = (addedEntries != null ? addedEntries.hashCode() : 0);
+ result = 31 * result + (removedEntries != null ? removedEntries.hashCode() : 0);
+ result = 31 * result + (modifiedEntries != null ? modifiedEntries.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Added Entries " + addedEntries + " Removeed Entries " + removedEntries + " Modified Entries " + modifiedEntries;
+ }
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/Util.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
16 years
JBoss Cache SVN: r6964 - in core/trunk/src/main/java/org/jboss/cache: transaction and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-15 16:24:43 -0400 (Wed, 15 Oct 2008)
New Revision: 6964
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
Log:
[JBCACHE-1428] Remove per-request DEBUG logging
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-10-15 20:23:22 UTC (rev 6963)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-10-15 20:24:43 UTC (rev 6964)
@@ -141,7 +141,7 @@
if (!sync && replicationQueue != null && !usingBuddyReplication)
{
- if (log.isDebugEnabled()) log.debug("Putting call " + call + " on the replication queue.");
+ if (trace) log.trace("Putting call " + call + " on the replication queue.");
replicationQueue.add(commandsFactory.buildReplicateCommand(call));
}
else
@@ -209,7 +209,7 @@
{
if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isCacheModeLocal())
{
- if (log.isDebugEnabled()) log.debug("LOCAL mode forced on invocation. Suppressing clustered events.");
+ if (trace) log.trace("LOCAL mode forced on invocation. Suppressing clustered events.");
return true;
}
return false;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-10-15 20:23:22 UTC (rev 6963)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-10-15 20:24:43 UTC (rev 6964)
@@ -117,7 +117,7 @@
Object result = null;
// this is a prepare, commit, or rollback.
- if (log.isDebugEnabled()) log.debug("Got gtx from invocation context " + ctx.getGlobalTransaction());
+ if (trace) log.trace("Got gtx from invocation context " + ctx.getGlobalTransaction());
try
{
if (ctx.getGlobalTransaction().isRemote())
@@ -165,7 +165,7 @@
// make sure we set this in the ctx
ctx.setTransaction(ltx);
}
- if (log.isDebugEnabled()) log.debug(" executing commit() with local TX " + ltx + " under global tx " + gtx);
+ if (trace) log.trace(" executing commit() with local TX " + ltx + " under global tx " + gtx);
txManager.commit();
if (getStatisticsEnabled()) commits++;
}
@@ -181,7 +181,7 @@
// this tx has completed. Clean up in the tx table.
txTable.remove(gtx, ltx);
}
- if (log.isDebugEnabled()) log.debug("Finished remote rollback method for " + gtx);
+ if (trace) log.trace("Finished remote rollback method for " + gtx);
}
catch (Throwable throwable)
{
@@ -223,7 +223,7 @@
// make sure we set this in the ctx
ctx.setTransaction(ltx);
}
- if (log.isDebugEnabled()) log.debug("executing with local TX " + ltx + " under global tx " + gtx);
+ if (trace) log.trace("executing with local TX " + ltx + " under global tx " + gtx);
txManager.rollback();
if (getStatisticsEnabled()) rollbacks++;
}
@@ -241,7 +241,7 @@
// this tx has completed. Clean up in the tx table.
txTable.remove(gtx, ltx);
}
- if (log.isDebugEnabled()) log.debug("Finished remote commit/rollback method for " + gtx);
+ if (trace) log.trace("Finished remote commit/rollback method for " + gtx);
}
catch (Throwable throwable)
{
@@ -322,8 +322,8 @@
txTable.put(ltx, gtx);
if (trace) log.trace("Created new tx for gtx " + gtx);
- if (log.isDebugEnabled())
- log.debug("Started new local tx as result of remote prepare: local tx=" + ltx + " (status=" + ltx.getStatus() + "), gtx=" + gtx);
+ if (trace)
+ log.trace("Started new local tx as result of remote prepare: local tx=" + ltx + " (status=" + ltx.getStatus() + "), gtx=" + gtx);
}
else
{
@@ -351,7 +351,7 @@
if (transactionContext == null)
{
// create a new transaction transactionContext
- if (log.isDebugEnabled()) log.debug("creating new tx transactionContext");
+ if (trace) log.trace("creating new tx transactionContext");
transactionContext = contextFactory.createTransactionContext(ltx);
txTable.put(gtx, transactionContext);
}
@@ -427,7 +427,7 @@
txManager.suspend();// suspends ltx - could be null
// resume whatever else we had going.
if (currentTx != null) txManager.resume(currentTx);
- if (log.isDebugEnabled()) log.debug("Finished remote prepare " + gtx);
+ if (trace) log.trace("Finished remote prepare " + gtx);
}
return retval;
@@ -518,7 +518,7 @@
ctx.setCommand(originalCommand);
ctx.setMethodCall(null);
}
- if (log.isDebugEnabled()) log.debug("Finished local commit/rollback method for " + gtx);
+ if (trace) log.trace("Finished local commit/rollback method for " + gtx);
return result;
}
@@ -909,17 +909,17 @@
{
case Status.STATUS_COMMITTED:
boolean onePhaseCommit = isOnePhaseCommit();
- if (log.isDebugEnabled()) log.debug("Running commit phase. One phase? " + onePhaseCommit);
+ if (trace) log.trace("Running commit phase. One phase? " + onePhaseCommit);
runCommitPhase(ctx, gtx, modifications, onePhaseCommit);
- log.debug("Finished commit phase");
+ log.trace("Finished commit phase");
break;
case Status.STATUS_UNKNOWN:
log.warn("Received JTA STATUS_UNKNOWN in afterCompletion()! XA resources may not be in sync. The app should manually clean up resources at this point.");
case Status.STATUS_MARKED_ROLLBACK:
case Status.STATUS_ROLLEDBACK:
- log.debug("Running rollback phase");
+ log.trace("Running rollback phase");
runRollbackPhase(ctx, gtx, tx);
- log.debug("Finished rollback phase");
+ log.trace("Finished rollback phase");
break;
default:
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-10-15 20:23:22 UTC (rev 6963)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-10-15 20:24:43 UTC (rev 6964)
@@ -48,11 +48,13 @@
protected DummyBaseTransactionManager tm_;
protected final Set<Synchronization> participants = new CopyOnWriteArraySet<Synchronization>();
+ private boolean trace;
public DummyTransaction(DummyBaseTransactionManager tm)
{
tm_ = tm;
status = Status.STATUS_ACTIVE;
+ trace = log.isTraceEnabled();
}
/**
@@ -254,9 +256,9 @@
throw new IllegalStateException("illegal status: " + status + " tx=" + this);
}
- if (log.isDebugEnabled())
+ if (trace)
{
- log.debug("registering synchronization handler " + sync);
+ log.trace("registering synchronization handler " + sync);
}
participants.add(sync);
@@ -273,9 +275,9 @@
for (Synchronization s : participants)
{
- if (log.isDebugEnabled())
+ if (trace)
{
- log.debug("processing beforeCompletion for " + s);
+ log.trace("processing beforeCompletion for " + s);
}
try
{
@@ -294,9 +296,9 @@
{
for (Synchronization s : participants)
{
- if (log.isDebugEnabled())
+ if (trace)
{
- log.debug("processing afterCompletion for " + s);
+ log.trace("processing afterCompletion for " + s);
}
try
{
16 years
JBoss Cache SVN: r6963 - core/trunk/src/test/java/org/jboss/cache/passivation.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-15 16:23:22 -0400 (Wed, 15 Oct 2008)
New Revision: 6963
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
Log:
[JBCACHE-1423] Port 2.2.X test to trunk
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-10-15 20:12:16 UTC (rev 6962)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-10-15 20:23:22 UTC (rev 6963)
@@ -805,8 +805,36 @@
assertTrue(children.contains("3"));
mgr.commit();
}
+
+
+ public void testPutDataMapAfterPassivation() throws Exception
+ {
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ CacheLoader loader = loaderTL.get();
+ Fqn f = Fqn.fromString("/a");
+ assert !cache.exists(f);
+ assert !loader.exists(f);
+
+ Map<Object, Object> input = new HashMap();
+ input.put("one", "one");
+ input.put("two", "two");
+ cache.put(f, input);
+
+ cache.evict(f);
+
+ input = new HashMap();
+ input.put("one", "oneA");
+ cache.put(f, input);
+
+ Map data = cache.getRoot().getChild(f).getData();
+ assertEquals("incorrect # of entries", 2, data.size());
+ assertEquals("Has key 'one", "oneA", data.get("one"));
+ assertEquals("Has key 'two", "two", data.get("two"));
+
+ }
+
public void testTxPutCommit() throws Exception
{
CacheSPI<Object, Object> cache = cacheTL.get();
16 years
JBoss Cache SVN: r6962 - in core/branches/2.2.X/src/main/java/org/jboss/cache: transaction and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-15 16:12:16 -0400 (Wed, 15 Oct 2008)
New Revision: 6962
Modified:
core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/branches/2.2.X/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
Log:
[JBCACHE-1428] Use trace field instead of log.isTraceEnabled()
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-10-15 19:59:40 UTC (rev 6961)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-10-15 20:12:16 UTC (rev 6962)
@@ -123,7 +123,7 @@
if (!sync && replicationQueue != null && !usingBuddyReplication)
{
- if (log.isDebugEnabled()) log.debug("Putting call " + call + " on the replication queue.");
+ if (trace) log.trace("Putting call " + call + " on the replication queue.");
replicationQueue.add(commandsFactory.buildReplicateCommand(call));
}
else
@@ -191,7 +191,7 @@
{
if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isCacheModeLocal())
{
- if (log.isTraceEnabled()) log.trace("LOCAL mode forced on invocation. Suppressing clustered events.");
+ if (trace) log.trace("LOCAL mode forced on invocation. Suppressing clustered events.");
return true;
}
return false;
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-10-15 19:59:40 UTC (rev 6961)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-10-15 20:12:16 UTC (rev 6962)
@@ -97,7 +97,7 @@
Object result = null;
// this is a prepare, commit, or rollback.
- if (log.isTraceEnabled()) log.trace("Got gtx from invocation context " + ctx.getGlobalTransaction());
+ if (trace) log.trace("Got gtx from invocation context " + ctx.getGlobalTransaction());
try
{
if (ctx.getGlobalTransaction().isRemote())
@@ -146,7 +146,7 @@
// make sure we set this in the ctx
ctx.setTransaction(ltx);
}
- if (log.isTraceEnabled()) log.trace(" executing commit() with local TX " + ltx + " under global tx " + gtx);
+ if (trace) log.trace(" executing commit() with local TX " + ltx + " under global tx " + gtx);
txManager.commit();
if (getStatisticsEnabled()) commits++;
}
@@ -162,7 +162,7 @@
// this tx has completed. Clean up in the tx table.
txTable.remove(gtx, ltx);
}
- if (log.isTraceEnabled()) log.trace("Finished remote rollback method for " + gtx);
+ if (trace) log.trace("Finished remote rollback method for " + gtx);
}
catch (Throwable throwable)
{
@@ -204,7 +204,7 @@
// make sure we set this in the ctx
ctx.setTransaction(ltx);
}
- if (log.isTraceEnabled()) log.trace("executing with local TX " + ltx + " under global tx " + gtx);
+ if (trace) log.trace("executing with local TX " + ltx + " under global tx " + gtx);
txManager.rollback();
if (getStatisticsEnabled()) rollbacks++;
}
@@ -222,7 +222,7 @@
// this tx has completed. Clean up in the tx table.
txTable.remove(gtx, ltx);
}
- if (log.isTraceEnabled()) log.trace("Finished remote commit/rollback method for " + gtx);
+ if (trace) log.trace("Finished remote commit/rollback method for " + gtx);
}
catch (Throwable throwable)
{
@@ -337,7 +337,7 @@
txTable.put(ltx, gtx);
if (trace) log.trace("Created new tx for gtx " + gtx);
- if (log.isTraceEnabled())
+ if (trace)
log.trace("Started new local tx as result of remote prepare: local tx=" + ltx + " (status=" + ltx.getStatus() + "), gtx=" + gtx);
}
else
@@ -366,7 +366,7 @@
if (entry == null)
{
// create a new transaction entry
- if (log.isTraceEnabled()) log.trace("creating new tx entry");
+ if (trace) log.trace("creating new tx entry");
entry = createNewTransactionEntry(ltx);
txTable.put(gtx, entry);
}
@@ -442,7 +442,7 @@
txManager.suspend();// suspends ltx - could be null
// resume whatever else we had going.
if (currentTx != null) txManager.resume(currentTx);
- if (log.isTraceEnabled()) log.trace("Finished remote prepare " + gtx);
+ if (trace) log.trace("Finished remote prepare " + gtx);
}
return retval;
@@ -545,7 +545,7 @@
ctx.setCommand(originalCommand);
ctx.setMethodCall(null);
}
- if (log.isTraceEnabled()) log.trace("Finished local commit/rollback method for " + gtx);
+ if (trace) log.trace("Finished local commit/rollback method for " + gtx);
return result;
}
@@ -969,7 +969,7 @@
{
case Status.STATUS_COMMITTED:
boolean onePhaseCommit = isOnePhaseCommit();
- if (log.isTraceEnabled()) log.trace("Running commit phase. One phase? " + onePhaseCommit);
+ if (trace) log.trace("Running commit phase. One phase? " + onePhaseCommit);
runCommitPhase(ctx, gtx, modifications, onePhaseCommit);
log.trace("Finished commit phase");
break;
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-10-15 19:59:40 UTC (rev 6961)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-10-15 20:12:16 UTC (rev 6962)
@@ -27,11 +27,13 @@
DummyBaseTransactionManager tm_;
protected final Set<Synchronization> participants = new CopyOnWriteArraySet<Synchronization>();
+ private boolean trace;
public DummyTransaction(DummyBaseTransactionManager tm)
{
tm_ = tm;
status = Status.STATUS_ACTIVE;
+ trace = log.isTraceEnabled();
}
/**
@@ -234,7 +236,7 @@
throw new IllegalStateException("illegal status: " + status + " tx=" + this);
}
- if (log.isTraceEnabled())
+ if (trace)
{
log.trace("registering synchronization handler " + sync);
}
@@ -253,7 +255,7 @@
for (Synchronization s : participants)
{
- if (log.isTraceEnabled())
+ if (trace)
{
log.trace("processing beforeCompletion for " + s);
}
@@ -274,7 +276,7 @@
{
for (Synchronization s : participants)
{
- if (log.isTraceEnabled())
+ if (trace)
{
log.trace("processing afterCompletion for " + s);
}
16 years
JBoss Cache SVN: r6961 - in core/branches/2.2.X/src/main/java/org/jboss/cache: transaction and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-10-15 15:59:40 -0400 (Wed, 15 Oct 2008)
New Revision: 6961
Modified:
core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/branches/2.2.X/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
Log:
[JBCACHE-1428] Remove per-request DEBUG logging
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-10-15 19:41:25 UTC (rev 6960)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-10-15 19:59:40 UTC (rev 6961)
@@ -191,7 +191,7 @@
{
if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isCacheModeLocal())
{
- if (log.isDebugEnabled()) log.debug("LOCAL mode forced on invocation. Suppressing clustered events.");
+ if (log.isTraceEnabled()) log.trace("LOCAL mode forced on invocation. Suppressing clustered events.");
return true;
}
return false;
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-10-15 19:41:25 UTC (rev 6960)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-10-15 19:59:40 UTC (rev 6961)
@@ -97,7 +97,7 @@
Object result = null;
// this is a prepare, commit, or rollback.
- if (log.isDebugEnabled()) log.debug("Got gtx from invocation context " + ctx.getGlobalTransaction());
+ if (log.isTraceEnabled()) log.trace("Got gtx from invocation context " + ctx.getGlobalTransaction());
try
{
if (ctx.getGlobalTransaction().isRemote())
@@ -146,7 +146,7 @@
// make sure we set this in the ctx
ctx.setTransaction(ltx);
}
- if (log.isDebugEnabled()) log.debug(" executing commit() with local TX " + ltx + " under global tx " + gtx);
+ if (log.isTraceEnabled()) log.trace(" executing commit() with local TX " + ltx + " under global tx " + gtx);
txManager.commit();
if (getStatisticsEnabled()) commits++;
}
@@ -162,7 +162,7 @@
// this tx has completed. Clean up in the tx table.
txTable.remove(gtx, ltx);
}
- if (log.isDebugEnabled()) log.debug("Finished remote rollback method for " + gtx);
+ if (log.isTraceEnabled()) log.trace("Finished remote rollback method for " + gtx);
}
catch (Throwable throwable)
{
@@ -204,7 +204,7 @@
// make sure we set this in the ctx
ctx.setTransaction(ltx);
}
- if (log.isDebugEnabled()) log.debug("executing with local TX " + ltx + " under global tx " + gtx);
+ if (log.isTraceEnabled()) log.trace("executing with local TX " + ltx + " under global tx " + gtx);
txManager.rollback();
if (getStatisticsEnabled()) rollbacks++;
}
@@ -222,7 +222,7 @@
// this tx has completed. Clean up in the tx table.
txTable.remove(gtx, ltx);
}
- if (log.isDebugEnabled()) log.debug("Finished remote commit/rollback method for " + gtx);
+ if (log.isTraceEnabled()) log.trace("Finished remote commit/rollback method for " + gtx);
}
catch (Throwable throwable)
{
@@ -337,8 +337,8 @@
txTable.put(ltx, gtx);
if (trace) log.trace("Created new tx for gtx " + gtx);
- if (log.isDebugEnabled())
- log.debug("Started new local tx as result of remote prepare: local tx=" + ltx + " (status=" + ltx.getStatus() + "), gtx=" + gtx);
+ if (log.isTraceEnabled())
+ log.trace("Started new local tx as result of remote prepare: local tx=" + ltx + " (status=" + ltx.getStatus() + "), gtx=" + gtx);
}
else
{
@@ -366,7 +366,7 @@
if (entry == null)
{
// create a new transaction entry
- if (log.isDebugEnabled()) log.debug("creating new tx entry");
+ if (log.isTraceEnabled()) log.trace("creating new tx entry");
entry = createNewTransactionEntry(ltx);
txTable.put(gtx, entry);
}
@@ -442,7 +442,7 @@
txManager.suspend();// suspends ltx - could be null
// resume whatever else we had going.
if (currentTx != null) txManager.resume(currentTx);
- if (log.isDebugEnabled()) log.debug("Finished remote prepare " + gtx);
+ if (log.isTraceEnabled()) log.trace("Finished remote prepare " + gtx);
}
return retval;
@@ -545,7 +545,7 @@
ctx.setCommand(originalCommand);
ctx.setMethodCall(null);
}
- if (log.isDebugEnabled()) log.debug("Finished local commit/rollback method for " + gtx);
+ if (log.isTraceEnabled()) log.trace("Finished local commit/rollback method for " + gtx);
return result;
}
@@ -969,17 +969,17 @@
{
case Status.STATUS_COMMITTED:
boolean onePhaseCommit = isOnePhaseCommit();
- if (log.isDebugEnabled()) log.debug("Running commit phase. One phase? " + onePhaseCommit);
+ if (log.isTraceEnabled()) log.trace("Running commit phase. One phase? " + onePhaseCommit);
runCommitPhase(ctx, gtx, modifications, onePhaseCommit);
- log.debug("Finished commit phase");
+ log.trace("Finished commit phase");
break;
case Status.STATUS_UNKNOWN:
log.warn("Received JTA STATUS_UNKNOWN in afterCompletion()! XA resources may not be in sync. The app should manually clean up resources at this point.");
case Status.STATUS_MARKED_ROLLBACK:
case Status.STATUS_ROLLEDBACK:
- log.debug("Running rollback phase");
+ log.trace("Running rollback phase");
runRollbackPhase(ctx, gtx, tx, modifications);
- log.debug("Finished rollback phase");
+ log.trace("Finished rollback phase");
break;
default:
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-10-15 19:41:25 UTC (rev 6960)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-10-15 19:59:40 UTC (rev 6961)
@@ -234,9 +234,9 @@
throw new IllegalStateException("illegal status: " + status + " tx=" + this);
}
- if (log.isDebugEnabled())
+ if (log.isTraceEnabled())
{
- log.debug("registering synchronization handler " + sync);
+ log.trace("registering synchronization handler " + sync);
}
participants.add(sync);
@@ -253,9 +253,9 @@
for (Synchronization s : participants)
{
- if (log.isDebugEnabled())
+ if (log.isTraceEnabled())
{
- log.debug("processing beforeCompletion for " + s);
+ log.trace("processing beforeCompletion for " + s);
}
try
{
@@ -274,9 +274,9 @@
{
for (Synchronization s : participants)
{
- if (log.isDebugEnabled())
+ if (log.isTraceEnabled())
{
- log.debug("processing afterCompletion for " + s);
+ log.trace("processing afterCompletion for " + s);
}
try
{
16 years