Author: julien_viet
Date: 2010-01-18 09:04:19 -0500 (Mon, 18 Jan 2010)
New Revision: 1351
Removed:
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/AtomicPositiveLong.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/BoundedBuffer.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/LongSampler.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/ObjectRef.java
portal/trunk/component/scripting/src/test/java/org/exoplatform/commons/
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/SerializationMode.java
Log:
- remove classes moved to common package
- minor mod on serialization mode
Deleted:
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/AtomicPositiveLong.java
===================================================================
---
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/AtomicPositiveLong.java 2010-01-18
13:24:19 UTC (rev 1350)
+++
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/AtomicPositiveLong.java 2010-01-18
14:04:19 UTC (rev 1351)
@@ -1,112 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.commons.utils;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * Extends the @link{AtomicLong} to contain positive longs. If no initial value
- * is provided when the object is created then the value is -1 to indicate that
- * it is not yet initialized.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- * @todo move to common utils
- */
-public class AtomicPositiveLong extends AtomicLong
-{
-
- /**
- * Create an atomic positive long with an inital provided value.
- *
- * @param initialValue the initial value
- * @throws IllegalArgumentException if the value is negative
- */
- public AtomicPositiveLong(long initialValue) throws IllegalArgumentException
- {
- super(initialValue);
-
- //
- if (initialValue == -1)
- {
- throw new IllegalArgumentException();
- }
- }
-
- /**
- * Create an atomic positive long with no initial value.
- */
- public AtomicPositiveLong()
- {
- super(-1);
- }
-
- /**
- * Update the value if the new value is greater than the previous one or if the long
is not initialized.
- *
- * @param newValue the new value
- * @throws IllegalArgumentException if the new value is negative
- */
- public void setIfGreater(long newValue) throws IllegalArgumentException
- {
- if (newValue < 0)
- {
- throw new IllegalArgumentException();
- }
- while (true)
- {
- long oldValue = get();
- if (newValue > oldValue || oldValue == -1)
- {
- compareAndSet(oldValue, newValue);
- }
- else
- {
- break;
- }
- }
- }
-
- /**
- * Update the value if the new value is lower than the previous one or if the long is
not initialized.
- *
- * @param newValue the new value
- * @throws IllegalArgumentException if the new value is negative
- */
- public void setIfLower(long newValue) throws IllegalArgumentException
- {
- if (newValue < 0)
- {
- throw new IllegalArgumentException();
- }
- while (true)
- {
- long oldValue = get();
- if (newValue < oldValue || oldValue == -1)
- {
- compareAndSet(oldValue, newValue);
- }
- else
- {
- break;
- }
- }
- }
-}
Deleted:
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/BoundedBuffer.java
===================================================================
---
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/BoundedBuffer.java 2010-01-18
13:24:19 UTC (rev 1350)
+++
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/BoundedBuffer.java 2010-01-18
14:04:19 UTC (rev 1351)
@@ -1,186 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.commons.utils;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- * <p>A thread safe bounded buffer.</p>
- *
- * <p>The idea of this class is that it retains only the last elements added
- * to the buffer up to a determined size, but it is possible to make snapshot of the
buffer elements and iterate
- * over them with a neglectable impact on synchronization.</p>
- *
- * <p>It maintains a linked list. When a new element is added, the first element
will have for
- * successor that new element. If the number of elements is greater than the max size
then the last element
- * is discarded.</p>
- *
- * <p> When a snapshot for iteration is required, the class only needs to keep a
reference to the last element of the list
- * and keep also the actual size of the list. The copy is made in an atomic manner for
consistency. Note that this class
- * expose only a notion of iterator to its client instead of a notion of list as iterator
have a notion of being short
- * lived objects. Indeed keeping a reference on an iterator would create a memory leak
and so this class must be used
- * with caution.</p>
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- * @todo move to common utils
- * @todo develop a non blocking implementation pretty much like the ConcurrentLinkedQueue
does
- * @todo although I don't think this class is a bottleneck as there is very short
lived synchronization
- * @todo and actually I don't know if it's feasible to have a non blocking impl
due to the size value
- *
- */
-public class BoundedBuffer<T> implements Iterable<T>
-{
-
- /** The max size. */
- private final int maxSize;
-
- /** The elder element. */
- private ObjectRef<T> last;
-
- /** The younger element. */
- private ObjectRef<T> first;
-
- /** The size, it is declared as volatile for the @link{getSize()} method. */
- private volatile int size;
-
- public BoundedBuffer(int maxSize)
- {
- if (maxSize < 1)
- {
- throw new IllegalArgumentException("Buffer size needs to be greater than
zero");
- }
-
- //
- this.maxSize = maxSize;
- this.size = 0;
- }
-
- public int getMaxSize()
- {
- return maxSize;
- }
-
- public int getSize()
- {
- return size;
- }
-
- /**
- * Add an element to the buffer.
- *
- * @param t the element to add
- */
- public void add(T t)
- {
- synchronized (this)
- {
- if (first == null)
- {
- first = new ObjectRef<T>(t);
- last = first;
- size = 1;
- }
- else
- {
- ObjectRef<T> tmp = first;
- first = new ObjectRef<T>(t);
- tmp.next.set(first);
- if (size < maxSize)
- {
- size++;
- }
- else
- {
- last = last.next.get();
- }
- }
- }
- }
-
- /**
- * Make a snapshot of the buffer and iterate over the elements. It is important to not
keep reference
- * on an iterator returned by this method otherwise it could create a memory leak.
- *
- * @return an iterator over the elements
- */
- public Iterator<T> iterator()
- {
- if (size == 0)
- {
- List<T> empty = Collections.emptyList();
- return empty.iterator();
- }
- else
- {
- // Get consistent state
- final ObjectRef<T> lastSnapshot;
- final int sizeSnapshot;
- synchronized (this)
- {
- lastSnapshot = last;
- sizeSnapshot = size;
- }
- return new BoundedIterator<T>(lastSnapshot, sizeSnapshot);
- }
- }
-
- private static final class BoundedIterator<T> implements Iterator<T>
- {
-
- final int size;
-
- ObjectRef<T> current;
-
- int count = 0;
-
- private BoundedIterator(ObjectRef<T> current, int size)
- {
- this.current = current;
- this.size = size;
- this.count = 0;
- }
-
- public boolean hasNext()
- {
- return count < size && current != null;
- }
-
- public T next()
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- T next = current.object;
- current = current.next.get();
- count++;
- return next;
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- }
-}
Deleted:
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/LongSampler.java
===================================================================
---
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/LongSampler.java 2010-01-18
13:24:19 UTC (rev 1350)
+++
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/LongSampler.java 2010-01-18
14:04:19 UTC (rev 1351)
@@ -1,74 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.commons.utils;
-
-/**
- * An object that sample long values.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- * @todo move to common utils
- */
-public class LongSampler extends BoundedBuffer<Long>
-{
-
- public LongSampler(int maxSize)
- {
- super(maxSize);
- }
-
- /**
- * Returns the average value.
- *
- * @return the average
- */
- public double average()
- {
- long sumTime = 0;
- int size = 0;
- for (long value : this)
- {
- sumTime += value;
- size++;
- }
- return size == 0 ? 0 : (double)sumTime / (double)size;
- }
-
- /**
- * Returns the number of values which are greater or equals to the threshold value.
- *
- * @param threshold the threshold value
- * @return the count of values above the provided threshold
- */
- public int countAboveThreshold(long threshold)
- {
- System.out.println("bbb" + threshold);
- int count = 0;
- for (long value : this)
- {
- System.out.println("aaaa" + value);
- if (value >= threshold)
- {
- count++;
- }
- }
- return count;
- }
-}
Deleted:
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/ObjectRef.java
===================================================================
---
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/ObjectRef.java 2010-01-18
13:24:19 UTC (rev 1350)
+++
portal/trunk/component/scripting/src/main/java/org/exoplatform/commons/utils/ObjectRef.java 2010-01-18
14:04:19 UTC (rev 1351)
@@ -1,45 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.commons.utils;
-
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * An internal class to keep a reference onto another object, it is used in the bounded
buffer implementation.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- * @todo move to common utils
- */
-class ObjectRef<T>
-{
-
- /** . */
- final T object;
-
- /** . */
- final AtomicReference<ObjectRef<T>> next;
-
- ObjectRef(T object)
- {
- this.object = object;
- this.next = new AtomicReference<ObjectRef<T>>();
- }
-}
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/SerializationMode.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/SerializationMode.java 2010-01-18
13:24:19 UTC (rev 1350)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/SerializationMode.java 2010-01-18
14:04:19 UTC (rev 1351)
@@ -30,6 +30,8 @@
SERIALIZABLE,
+ STATELESS,
+
NONE