repo
stringlengths
1
191
file
stringlengths
23
351
code
stringlengths
0
5.32M
file_length
int64
0
5.32M
avg_line_length
float64
0
2.9k
max_line_length
int64
0
288k
extension_type
stringclasses
1 value
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanPassivationConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., 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.wildfly.clustering.ejb.bean; /** * Configuration for bean passivation. * @author Paul Ferraro */ public interface BeanPassivationConfiguration { /** * Returns the maximum number of bean instances to retain in memory at a given time. * @return the maximum number of bean instances to retain in memory at a given time, or null if passivation is disabled. */ Integer getMaxActiveBeans(); }
1,449
40.428571
124
java
null
wildfly-main/clustering/ejb/client/src/test/java/org/wildfly/clustering/ejb/client/TestEJBClientSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.client; import org.infinispan.protostream.SerializationContextInitializer; import org.kohsuke.MetaInfServices; /** * {@link SerializationContextInitializer} service for this module * @author Paul Ferraro */ @MetaInfServices(SerializationContextInitializer.class) public class TestEJBClientSerializationContextInitializer extends EJBClientSerializationContextInitializer { }
1,439
39
108
java
null
wildfly-main/clustering/ejb/client/src/test/java/org/wildfly/clustering/ejb/client/SessionIDSerializerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., 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.wildfly.clustering.ejb.client; import java.io.IOException; import java.nio.ByteBuffer; import java.util.UUID; import org.jboss.ejb.client.SessionID; import org.jboss.ejb.client.UUIDSessionID; import org.junit.Test; import org.wildfly.clustering.ejb.client.SessionIDSerializer.BasicSessionIDExternalizer; import org.wildfly.clustering.ejb.client.SessionIDSerializer.UUIDSessionIDExternalizer; import org.wildfly.clustering.ejb.client.SessionIDSerializer.UnknownSessionIDExternalizer; import org.wildfly.clustering.marshalling.ExternalizerTesterFactory; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Unit test for {@link SessionIDSerializer}. * @author Paul Ferraro */ public class SessionIDSerializerTestCase { @Test public void testProtoStream() throws IOException { test(ProtoStreamTesterFactory.INSTANCE.createTester()); } @Test public void testExternalizer() throws IOException { test(new ExternalizerTesterFactory(new UUIDSessionIDExternalizer(), new BasicSessionIDExternalizer(), new UnknownSessionIDExternalizer()).createTester()); } private static void test(Tester<SessionID> tester) throws IOException { UUID uuid = UUID.randomUUID(); tester.test(new UUIDSessionID(uuid)); ByteBuffer buffer = ByteBuffer.allocate(20); buffer.putInt(0x07000000); buffer.putLong(uuid.getMostSignificantBits()); buffer.putLong(uuid.getLeastSignificantBits()); tester.test(SessionID.createSessionID(buffer.array())); buffer = ByteBuffer.allocate(16); buffer.putLong(uuid.getMostSignificantBits()); buffer.putLong(uuid.getLeastSignificantBits()); tester.test(SessionID.createSessionID(buffer.array())); } }
2,869
37.783784
162
java
null
wildfly-main/clustering/ejb/client/src/main/java/org/wildfly/clustering/ejb/client/EJBClientSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.client; import org.infinispan.protostream.SerializationContext; import org.infinispan.protostream.SerializationContextInitializer; import org.jboss.ejb.client.SessionID; import org.wildfly.clustering.marshalling.protostream.AbstractSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.FunctionalScalarMarshaller; import org.wildfly.clustering.marshalling.protostream.Scalar; /** * {@link SerializationContextInitializer} service for this module * @author Paul Ferraro */ public class EJBClientSerializationContextInitializer extends AbstractSerializationContextInitializer { public EJBClientSerializationContextInitializer() { super("org.jboss.ejb.client.proto"); } @Override public void registerMarshallers(SerializationContext context) { context.registerMarshaller(new FunctionalScalarMarshaller<>(SessionID.class, Scalar.BYTE_ARRAY.cast(byte[].class), SessionID::getEncodedForm, SessionID::createSessionID)); } }
2,052
42.680851
179
java
null
wildfly-main/clustering/ejb/client/src/main/java/org/wildfly/clustering/ejb/client/EJBProxyResolver.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.client; import org.jboss.ejb.client.EJBClient; import org.jboss.marshalling.ObjectResolver; /** * Resolver for EJB proxies. * @author Paul Ferraro */ public class EJBProxyResolver implements ObjectResolver { @Override public Object readResolve(Object replacement) { return replacement; } @Override public Object writeReplace(Object object) { return EJBClient.isEJBProxy(object) ? new SerializableEJBProxy(object) : object; } }
1,533
33.863636
88
java
null
wildfly-main/clustering/ejb/client/src/main/java/org/wildfly/clustering/ejb/client/SerializableEJBProxy.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.client; import java.io.ObjectStreamException; import java.io.Serializable; import org.jboss.ejb.client.EJBClient; import org.jboss.ejb.client.EJBLocator; /** * Serializes an EJB proxy via its serializable locator. * @author Paul Ferraro */ public class SerializableEJBProxy implements Serializable { private static final long serialVersionUID = 2301976566323836449L; private final EJBLocator<? extends Object> locator; SerializableEJBProxy(Object proxy) { this.locator = EJBClient.getLocatorFor(proxy); } @SuppressWarnings("unused") private Object readResolve() throws ObjectStreamException { return EJBClient.createProxy(this.locator); } }
1,752
35.520833
70
java
null
wildfly-main/clustering/ejb/client/src/main/java/org/wildfly/clustering/ejb/client/EJBProxyObjectTable.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.client; import java.io.IOException; import org.jboss.ejb.client.EJBClient; import org.jboss.marshalling.Marshaller; import org.jboss.marshalling.ObjectTable; import org.jboss.marshalling.Unmarshaller; import org.jboss.marshalling.ObjectTable.Writer; /** * An {@link ObjectTable} for marshalling an EJB proxy. * @author Paul Ferraro * @deprecated Superseded by {@link EJBProxyResolver}. */ @Deprecated public class EJBProxyObjectTable implements ObjectTable, Writer { @Override public Writer getObjectWriter(Object o) throws IOException { if (o == null) { return null; } // we just care about Jakarta Enterprise Beans proxies if (!EJBClient.isEJBProxy(o)) { return null; } return this; } @Override public Object readObject(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException { return unmarshaller.readObject(); } @Override public void writeObject(Marshaller marshaller, Object object) throws IOException { marshaller.writeObject(new SerializableEJBProxy(object)); } }
2,178
33.587302
100
java
null
wildfly-main/clustering/ejb/client/src/main/java/org/wildfly/clustering/ejb/client/SessionIDSerializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., 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.wildfly.clustering.ejb.client; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import org.jboss.ejb.client.BasicSessionID; import org.jboss.ejb.client.SessionID; import org.jboss.ejb.client.UUIDSessionID; import org.jboss.ejb.client.UnknownSessionID; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.IndexSerializer; import org.wildfly.clustering.marshalling.spi.Serializer; import org.wildfly.clustering.marshalling.spi.SerializerExternalizer; /** * @author Paul Ferraro */ public enum SessionIDSerializer implements Serializer<SessionID> { INSTANCE; @Override public void write(DataOutput output, SessionID id) throws IOException { byte[] encoded = id.getEncodedForm(); IndexSerializer.UNSIGNED_BYTE.writeInt(output, encoded.length); output.write(encoded); } @Override public SessionID read(DataInput input) throws IOException { byte[] encoded = new byte[IndexSerializer.UNSIGNED_BYTE.readInt(input)]; input.readFully(encoded); return SessionID.createSessionID(encoded); } @MetaInfServices(Externalizer.class) public static class BasicSessionIDExternalizer extends SerializerExternalizer<SessionID> { @SuppressWarnings("unchecked") public BasicSessionIDExternalizer() { super((Class<SessionID>) (Class<?>) BasicSessionID.class, INSTANCE); } } @MetaInfServices(Externalizer.class) public static class UnknownSessionIDExternalizer extends SerializerExternalizer<SessionID> { @SuppressWarnings("unchecked") public UnknownSessionIDExternalizer() { super((Class<SessionID>) (Class<?>) UnknownSessionID.class, INSTANCE); } } @MetaInfServices(Externalizer.class) public static class UUIDSessionIDExternalizer extends SerializerExternalizer<SessionID> { @SuppressWarnings("unchecked") public UUIDSessionIDExternalizer() { super((Class<SessionID>) (Class<?>) UUIDSessionID.class, INSTANCE); } } }
3,177
37.756098
96
java
null
wildfly-main/clustering/ejb/cache/src/test/java/org/wildfly/clustering/ejb/cache/bean/SimpleBeanCreationMetaDataMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.io.IOException; import java.util.UUID; import org.jboss.ejb.client.SessionID; import org.jboss.ejb.client.UUIDSessionID; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Unit test for {@link SimpleBeanEntryMarshaller}. * @author Paul Ferraro */ public class SimpleBeanCreationMetaDataMarshallerTestCase { @Test public void test() throws IOException { SessionID id = new UUIDSessionID(UUID.randomUUID()); BeanCreationMetaData<SessionID> metaData = new SimpleBeanCreationMetaData<>("foo", id); Tester<BeanCreationMetaData<SessionID>> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(metaData, SimpleBeanCreationMetaDataMarshallerTestCase::assertEquals); } static void assertEquals(BeanCreationMetaData<SessionID> metaData1, BeanCreationMetaData<SessionID> metaData2) { Assert.assertEquals(metaData1.getName(), metaData2.getName()); Assert.assertEquals(metaData1.getGroupId(), metaData2.getGroupId()); Assert.assertEquals(metaData1.getCreationTime(), metaData2.getCreationTime()); } }
2,306
40.945455
116
java
null
wildfly-main/clustering/ejb/cache/src/test/java/org/wildfly/clustering/ejb/cache/bean/TestSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.util.List; import org.infinispan.protostream.SerializationContextInitializer; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.ejb.client.EJBClientSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.CompositeSerializationContextInitializer; /** * A {@link SerializationContextInitializer} that registers the requisite marshallers for use by this module's marshalling tests. * @author Paul Ferraro */ @MetaInfServices(SerializationContextInitializer.class) public class TestSerializationContextInitializer extends CompositeSerializationContextInitializer { public TestSerializationContextInitializer() { super(List.of(new EJBClientSerializationContextInitializer(), new BeanSerializationContextInitializer())); } }
1,871
43.571429
129
java
null
wildfly-main/clustering/ejb/cache/src/test/java/org/wildfly/clustering/ejb/cache/bean/SimpleBeanAccessMetaDataMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.io.IOException; import java.time.Duration; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Unit test for {@link SimpleBeanAccessMetaDataMarshaller}. * @author Paul Ferraro */ public class SimpleBeanAccessMetaDataMarshallerTestCase { @Test public void test() throws IOException { BeanAccessMetaData metaData = new SimpleBeanAccessMetaData(); Tester<BeanAccessMetaData> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(metaData, SimpleBeanAccessMetaDataMarshallerTestCase::assertEquals); metaData.setLastAccessDuration(Duration.ofSeconds(10)); tester.test(metaData, SimpleBeanAccessMetaDataMarshallerTestCase::assertEquals); } static void assertEquals(BeanAccessMetaData metaData1, BeanAccessMetaData metaData2) { Assert.assertEquals(metaData1.getLastAccessDuration(), metaData2.getLastAccessDuration()); } }
2,124
39.865385
98
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/ImmutableBeanGroupManager.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.BeanInstance; /** * Manages immutable groups of beans. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface ImmutableBeanGroupManager<K, V extends BeanInstance<K>> { ImmutableBeanGroup<K, V> getImmutableBeanGroup(K id); }
1,408
37.081081
74
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/OnCloseBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.util.function.Consumer; import org.wildfly.clustering.ejb.bean.Bean; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.ejb.bean.BeanMetaData; /** * A bean decorator that executes a given task on close. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public class OnCloseBean<K, V extends BeanInstance<K>> implements Bean<K, V> { private final Bean<K, V> bean; private final Consumer<Bean<K, V>> task; public OnCloseBean(Bean<K, V> bean, Consumer<Bean<K, V>> task) { this.bean = bean; this.task = task; } @Override public K getId() { return this.bean.getId(); } @Override public V getInstance() { return this.bean.getInstance(); } @Override public BeanMetaData<K> getMetaData() { return this.bean.getMetaData(); } @Override public boolean isValid() { return this.bean.isValid(); } @Override public void remove(Consumer<V> removeTask) { this.bean.remove(removeTask); } @Override public void close() { try { this.task.accept(this.bean); } finally { this.bean.close(); } } }
2,346
28.3375
78
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanAccessMetaDataKey.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ee.Key; /** * The key used to cache the access metadata of a bean. * @author Paul Ferraro * @param <K> the bean identifier type */ public interface BeanAccessMetaDataKey<K> extends Key<K> { }
1,300
36.171429
70
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanMetaDataFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ee.Creator; import org.wildfly.clustering.ee.Remover; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.ejb.bean.BeanMetaData; /** * Factory for creating {@link BeanMetaData} instances. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean metadata value */ public interface BeanMetaDataFactory<K, V> extends ImmutableBeanMetaDataFactory<K, V>, Creator<BeanInstance<K>, V, K>, Remover<K> { BeanMetaData<K> createBeanMetaData(K id, V value); }
1,618
39.475
131
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanAccessMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.time.Duration; /** * Describes the metadata of a cached bean that changes per invocation/transaction. * @author Paul Ferraro */ public interface BeanAccessMetaData extends ImmutableBeanAccessMetaData { /** * Sets the duration of time since creation for this bean. * @param duration the duration of time since bean creation. */ void setLastAccessDuration(Duration duration); }
1,488
37.179487
83
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ee.Creator; import org.wildfly.clustering.ee.Remover; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.ejb.bean.BeanMetaData; /** * A factory for creating {@link MutableBean} instances from a {@link BeanMetaDataFactory} and a {@link BeanGroupManager}. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type * @param <M> the bean metadata value type */ public interface BeanFactory<K, V extends BeanInstance<K>, M> extends ImmutableBeanFactory<K, V, M>, Creator<V, M, K>, Remover<K> { @Override BeanMetaDataFactory<K, M> getMetaDataFactory(); @Override BeanGroupManager<K, V> getBeanGroupManager(); @Override default M createValue(V id, K groupId) { return this.getMetaDataFactory().createValue(id, groupId); } @Override default boolean remove(K id) { return this.getMetaDataFactory().remove(id); } @Override default boolean purge(K id) { return this.getMetaDataFactory().purge(id); } default MutableBean<K, V> createBean(K id, M value) { BeanMetaData<K> metaData = this.getMetaDataFactory().createBeanMetaData(id, value); BeanGroup<K, V> group = this.getBeanGroupManager().getBeanGroup(metaData.getGroupId()); return this.createBean(id, metaData, group); } MutableBean<K, V> createBean(K id, BeanMetaData<K> metaData, BeanGroup<K, V> group); }
2,546
37.590909
131
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanGroupManager.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.BeanInstance; /** * Manages mutable and immutable groups of beans. * @author Paul Ferraro * @param <K> the bean and bean group identifier type * @param <V> the bean instance type */ public interface BeanGroupManager<K, V extends BeanInstance<K>> extends ImmutableBeanGroupManager<K, V> { @Override default ImmutableBeanGroup<K, V> getImmutableBeanGroup(K id) { return this.getBeanGroup(id); } BeanGroup<K, V> getBeanGroup(K id); }
1,574
36.5
105
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/CompositeBeanMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.time.Duration; import java.time.Instant; import java.time.temporal.ChronoUnit; import org.wildfly.clustering.ejb.bean.BeanExpiration; import org.wildfly.clustering.ejb.bean.BeanMetaData; /** * A {@link BeanMetaData} implementation composed from a {@link BeanCreationMetaData} and a {@link BeanAccessMetaData}. * @author Paul Ferraro * @param <K> the bean identifier type */ public class CompositeBeanMetaData<K> extends CompositeImmutableBeanMetaData<K> implements BeanMetaData<K> { private final BeanCreationMetaData<K> creationMetaData; private final BeanAccessMetaData accessMetaData; public CompositeBeanMetaData(BeanCreationMetaData<K> creationMetaData, BeanAccessMetaData accessMetaData, BeanExpiration expiration) { super(creationMetaData, accessMetaData, expiration); this.creationMetaData = creationMetaData; this.accessMetaData = accessMetaData; } @Override public void setLastAccessTime(Instant lastAccessedTime) { // Only retain millisecond precision Duration duration = Duration.between(this.creationMetaData.getCreationTime(), lastAccessedTime); this.accessMetaData.setLastAccessDuration((duration.getNano() == 0) ? duration : duration.truncatedTo(ChronoUnit.MILLIS).plusMillis(1)); } }
2,370
42.109091
144
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanManagerConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.group.Group; /** * Encapsulates the configuration of a {@link org.wildfly.clustering.ejb.bean.BeanManager} implementation. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface BeanManagerConfiguration<K, V extends BeanInstance<K>, M> extends org.wildfly.clustering.ejb.bean.BeanManagerConfiguration<K, V>, BeanMetaDataFactoryConfiguration { BeanFactory<K, V, M> getBeanFactory(); Group getGroup(); }
1,634
42.026316
182
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/CompositeBeanFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.ejb.bean.BeanMetaData; /** * A {@link BeanFactory} implementation that creates {@link CompositeBean} instances. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type * @param <M> the bean metadata value type */ public class CompositeBeanFactory<K, V extends BeanInstance<K>, M> extends CompositeImmutableBeanFactory<K, V, M> implements BeanFactory<K, V, M> { private final BeanMetaDataFactory<K, M> metaDataFactory; private final BeanGroupManager<K, V> groupManager; public CompositeBeanFactory(BeanMetaDataFactory<K, M> metaDataFactory, BeanGroupManager<K, V> groupManager) { super(metaDataFactory, groupManager); this.metaDataFactory = metaDataFactory; this.groupManager = groupManager; } @Override public MutableBean<K, V> createBean(K id, BeanMetaData<K> metaData, BeanGroup<K, V> group) { return new CompositeBean<>(id, metaData, group, this); } @Override public BeanMetaDataFactory<K, M> getMetaDataFactory() { return this.metaDataFactory; } @Override public BeanGroupManager<K, V> getBeanGroupManager() { return this.groupManager; } }
2,352
37.57377
147
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanGroup.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.BeanInstance; /** * Represents a group of SFSBs that must be serialized together. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface BeanGroup<K, V extends BeanInstance<K>> extends ImmutableBeanGroup<K, V> { /** * Adds the specified bean instance to this group. * @param instance a bean instance */ void addBeanInstance(V instance); /** * Removes the bean instance with the specified identifier from this group. * @param id a bean instance identifier * @return the removed bean instance, or null, if no such bean instance existed */ V removeBeanInstance(K id); }
1,798
37.276596
91
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanCreationMetaDataKey.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ee.Key; /** * The key used to cache the creation metadata of a bean. * @author Paul Ferraro * @param <K> the bean identifier type */ public interface BeanCreationMetaDataKey<K> extends Key<K> { }
1,304
36.285714
70
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/ImmortalBeanAccessMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.time.Duration; /** * A static {@link BeanAccessMetaData} implementation for beans that do not expire. * @author Paul Ferraro */ public enum ImmortalBeanAccessMetaData implements BeanAccessMetaData { INSTANCE; @Override public Duration getLastAccessDuration() { return Duration.ZERO; } @Override public void setLastAccessDuration(Duration duration) { // Do nothing } }
1,502
33.159091
83
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/MutableBeanGroup.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ee.Mutator; import org.wildfly.clustering.ejb.bean.BeanInstance; /** * A bean group with the ability to mutate. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface MutableBeanGroup<K, V extends BeanInstance<K>> extends BeanGroup<K, V>, Mutator { }
1,422
37.459459
98
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/SimpleBeanCreationMetaDataMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.io.IOException; import java.time.Instant; import org.infinispan.protostream.descriptors.WireType; import org.jboss.ejb.client.SessionID; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; /** * ProtoStream marshaller for a {@link SimpleBeanCreationMetaData}. * @author Paul Ferraro */ public class SimpleBeanCreationMetaDataMarshaller implements ProtoStreamMarshaller<SimpleBeanCreationMetaData<SessionID>> { private static final int NAME_INDEX = 1; private static final int GROUP_IDENTIFIER_INDEX = 2; private static final int CREATION_TIME_INDEX = 3; private static final Instant DEFAULT_CREATION_TIME = Instant.EPOCH; @SuppressWarnings("unchecked") @Override public Class<? extends SimpleBeanCreationMetaData<SessionID>> getJavaClass() { return (Class<SimpleBeanCreationMetaData<SessionID>>) (Class<?>) SimpleBeanCreationMetaData.class; } @Override public SimpleBeanCreationMetaData<SessionID> readFrom(ProtoStreamReader reader) throws IOException { String name = null; SessionID groupId = null; Instant creationTime = Instant.EPOCH; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case NAME_INDEX: name = reader.readString(); break; case GROUP_IDENTIFIER_INDEX: groupId = reader.readObject(SessionID.class); break; case CREATION_TIME_INDEX: creationTime = reader.readObject(Instant.class); break; default: reader.skipField(tag); } } return new SimpleBeanCreationMetaData<>(name, groupId, creationTime); } @Override public void writeTo(ProtoStreamWriter writer, SimpleBeanCreationMetaData<SessionID> metaData) throws IOException { String name = metaData.getName(); if (name != null) { writer.writeString(NAME_INDEX, name); } SessionID groupId = metaData.getGroupId(); if (groupId != null) { writer.writeObject(GROUP_IDENTIFIER_INDEX, groupId); } Instant creationTime = metaData.getCreationTime(); if (!DEFAULT_CREATION_TIME.equals(creationTime)) { writer.writeObject(CREATION_TIME_INDEX, creationTime); } } }
3,688
39.538462
123
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/ImmutableBeanAccessMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.time.Duration; /** * An immutable description of the metadata of a cached bean that changes per invocation/transaction. * @author Paul Ferraro */ public interface ImmutableBeanAccessMetaData { /** * Returns the duration of time between bean creation and last access. * @return */ Duration getLastAccessDuration(); }
1,429
35.666667
101
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.time.Duration; import org.infinispan.protostream.SerializationContext; import org.wildfly.clustering.marshalling.protostream.AbstractSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.FunctionalMarshaller; /** * {@link org.infinispan.protostream.SerializationContextInitializer} for this package. * @author Paul Ferraro */ public class BeanSerializationContextInitializer extends AbstractSerializationContextInitializer { @Override public void registerMarshallers(SerializationContext context) { context.registerMarshaller(new SimpleBeanCreationMetaDataMarshaller()); context.registerMarshaller(new FunctionalMarshaller<>(SimpleBeanAccessMetaData.class, Duration.class, SimpleBeanAccessMetaData::getLastAccessDuration, SimpleBeanAccessMetaData::valueOf)); } }
1,914
43.534884
195
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/MutableBeanAccessMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.time.Duration; import org.wildfly.clustering.ee.Mutator; /** * A {@link BeanAccessMetaData} implementation that triggers a mutator on modification. * @author Paul Ferraro */ public class MutableBeanAccessMetaData implements BeanAccessMetaData { private final BeanAccessMetaData metaData; private final Mutator mutator; public MutableBeanAccessMetaData(BeanAccessMetaData metaData, Mutator mutator) { this.metaData = metaData; this.mutator = mutator; } @Override public Duration getLastAccessDuration() { return this.metaData.getLastAccessDuration(); } @Override public void setLastAccessDuration(Duration duration) { this.metaData.setLastAccessDuration(duration); this.mutator.mutate(); } }
1,864
33.537037
87
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/SimpleBeanAccessMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.time.Duration; /** * A simple {@link BeanAccessMetaData} implementation. * @author Paul Ferraro */ public class SimpleBeanAccessMetaData implements BeanAccessMetaData { static SimpleBeanAccessMetaData valueOf(Duration duration) { SimpleBeanAccessMetaData metaData = new SimpleBeanAccessMetaData(); metaData.setLastAccessDuration(duration); return metaData; } private volatile Duration lastAccessDuration = Duration.ZERO; @Override public Duration getLastAccessDuration() { return this.lastAccessDuration; } @Override public void setLastAccessDuration(Duration duration) { this.lastAccessDuration = duration; } @Override public String toString() { StringBuilder builder = new StringBuilder(this.getClass().getSimpleName()).append(" { "); builder.append("last-accessed = ").append(this.lastAccessDuration); return builder.append(" }").toString(); } }
2,054
34.431034
97
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/ImmutableBeanMetaDataFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ee.Locator; import org.wildfly.clustering.ejb.bean.ImmutableBeanMetaData; /** * Factory for creating {@link ImmutableBeanMetaData} instances. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean metadata value type */ public interface ImmutableBeanMetaDataFactory<K, V> extends Locator<K, V> { ImmutableBeanMetaData<K> createImmutableBeanMetaData(K id, V value); }
1,507
39.756757
75
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/DefaultBeanGroup.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.util.Map; import java.util.function.Consumer; import org.wildfly.clustering.ee.Mutator; import org.wildfly.clustering.ejb.bean.BeanInstance; /** * A default {@link BeanGroup} implementation based on a map of bean instances. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public class DefaultBeanGroup<K, V extends BeanInstance<K>> extends DefaultImmutableBeanGroup<K, V> implements MutableBeanGroup<K, V> { private final Map<K, V> instances; private final Consumer<Map<K, V>> prePassivateTask; private final Mutator mutator; public DefaultBeanGroup(K id, Map<K, V> instances, Consumer<Map<K, V>> prePassivateTask, Mutator mutator, Runnable closeTask) { super(id, instances, closeTask); this.instances = instances; this.prePassivateTask = prePassivateTask; this.mutator = mutator; } @Override public void addBeanInstance(V instance) { this.instances.put(instance.getId(), instance); } @Override public V removeBeanInstance(K id) { return this.instances.remove(id); } @Override public void mutate() { this.prePassivateTask.accept(this.instances); this.mutator.mutate(); } }
2,341
34.484848
135
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/CompositeImmutableBeanMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.time.Duration; import java.time.Instant; import org.wildfly.clustering.ejb.bean.BeanExpiration; import org.wildfly.clustering.ejb.bean.ImmutableBeanMetaData; /** * An {@link ImmutableBeanMetaData} implementation composed from a {@link BeanCreationMetaData} and an {@link ImmutableBeanAccessMetaData}. * @author Paul Ferraro * @param <K> the bean identifier type */ public class CompositeImmutableBeanMetaData<K> implements ImmutableBeanMetaData<K> { private final BeanCreationMetaData<K> creationMetaData; private final ImmutableBeanAccessMetaData accessMetaData; private final BeanExpiration expiration; public CompositeImmutableBeanMetaData(BeanCreationMetaData<K> creationMetaData, ImmutableBeanAccessMetaData accessMetaData, BeanExpiration expiration) { this.creationMetaData = creationMetaData; this.accessMetaData = accessMetaData; this.expiration = expiration; } @Override public String getName() { return this.creationMetaData.getName(); } @Override public K getGroupId() { return this.creationMetaData.getGroupId(); } @Override public Instant getLastAccessTime() { return this.creationMetaData.getCreationTime().plus(this.accessMetaData.getLastAccessDuration()); } @Override public Duration getTimeout() { return (this.expiration != null) ? this.expiration.getTimeout() : null; } }
2,511
35.941176
156
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/DefaultBeanGroupManager.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.io.IOException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import java.util.function.Function; import org.jboss.logging.Logger; import org.wildfly.clustering.ee.Creator; import org.wildfly.clustering.ee.Manager; import org.wildfly.clustering.ee.Mutator; import org.wildfly.clustering.ee.MutatorFactory; import org.wildfly.clustering.ee.Remover; import org.wildfly.clustering.ee.cache.ConcurrentManager; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.marshalling.spi.MarshalledValue; import org.wildfly.clustering.marshalling.spi.MarshalledValueFactory; import org.wildfly.common.function.Functions; /** * A manager for bean groups that leverages a {@link Manager} to handle bean group lifecycle. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type * @param <C> the marshalled value context type */ public class DefaultBeanGroupManager<K, V extends BeanInstance<K>, C> implements BeanGroupManager<K, V> { static final Logger LOGGER = Logger.getLogger(DefaultBeanGroupManager.class); private final Creator<K, MarshalledValue<Map<K, V>, C>, MarshalledValue<Map<K, V>, C>> creator; private final MutatorFactory<K, MarshalledValue<Map<K, V>, C>> mutatorFactory; private final MarshalledValueFactory<C> factory; private final Manager<K, MutableBeanGroup<K, V>> manager; private final Consumer<Map<K, V>> postActivateTask; private final Consumer<Map<K, V>> prePassivateTask; public DefaultBeanGroupManager(DefaultBeanGroupManagerConfiguration<K, V, C> configuration) { this.creator = configuration.getCreator(); this.mutatorFactory = configuration.getMutatorFactory(); this.factory = configuration.getMarshalledValueFactory(); boolean persistent = configuration.getCacheProperties().isPersistent(); this.postActivateTask = persistent ? new MapValuesTask<>(BeanInstance::postActivate) : Functions.discardingConsumer(); this.prePassivateTask = persistent ? new MapValuesTask<>(BeanInstance::prePassivate) : Functions.discardingConsumer(); this.manager = new ConcurrentManager<>(Functions.discardingConsumer(), new NewBeanGroupCloseTask<>(configuration.getRemover())); } @Override public BeanGroup<K, V> getBeanGroup(K id) { Creator<K, MarshalledValue<Map<K, V>, C>, MarshalledValue<Map<K, V>, C>> creator = this.creator; MutatorFactory<K, MarshalledValue<Map<K, V>, C>> mutatorFactory = this.mutatorFactory; MarshalledValueFactory<C> factory = this.factory; Consumer<Map<K, V>> postActivateTask = this.postActivateTask; Consumer<Map<K, V>> prePassivateTask = this.prePassivateTask; Function<Runnable, MutableBeanGroup<K, V>> beanGroupFactory = new Function<>() { @Override public MutableBeanGroup<K, V> apply(Runnable closeTask) { Map<K, V> instances = new ConcurrentHashMap<>(); MarshalledValue<Map<K, V>, C> newValue = factory.createMarshalledValue(instances); MarshalledValue<Map<K, V>, C> value = creator.createValue(id, newValue); if (value != newValue) { try { instances = value.get(factory.getMarshallingContext()); postActivateTask.accept(instances); } catch (IOException e) { throw new IllegalStateException(e); } } Mutator mutator = mutatorFactory.createMutator(id, value); return new DefaultBeanGroup<>(id, instances, prePassivateTask, mutator, closeTask); } }; return this.manager.apply(id, beanGroupFactory); } private static class MapValuesTask<K, V> implements Consumer<Map<K, V>> { private final Consumer<V> task; MapValuesTask(Consumer<V> task) { this.task = task; } @Override public void accept(Map<K, V> instances) { instances.values().forEach(this.task); } } private static class NewBeanGroupCloseTask<K, V extends BeanInstance<K>, C> implements Consumer<MutableBeanGroup<K, V>> { private final Remover<K> remover; NewBeanGroupCloseTask(Remover<K> remover) { this.remover = remover; } @Override public void accept(MutableBeanGroup<K, V> group) { if (group.isEmpty()) { this.remover.remove(group.getId()); } else { group.mutate(); } } } }
5,757
43.984375
136
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/MutableBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.Bean; import org.wildfly.clustering.ejb.bean.BeanInstance; /** * A {@link Bean} that allows associating a bean instance. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface MutableBean<K, V extends BeanInstance<K>> extends Bean<K, V> { /** * Associates this bean with an instance. * @param instance */ void setInstance(V instance); }
1,540
35.690476
79
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanGroupManagerServiceNameProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.jboss.msc.service.ServiceName; import org.wildfly.clustering.ejb.DeploymentConfiguration; import org.wildfly.clustering.service.SimpleServiceNameProvider; /** * Provides the {@link ServiceName} for a service providing a bean group manager. * @author Paul Ferraro */ public class BeanGroupManagerServiceNameProvider extends SimpleServiceNameProvider { public BeanGroupManagerServiceNameProvider(DeploymentConfiguration config) { super(ServiceName.JBOSS.append("clustering", "ejb", "manager", config.getDeploymentName())); } }
1,629
40.794872
100
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanMarshallerFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.util.function.Function; import org.jboss.marshalling.MarshallingConfiguration; import org.jboss.marshalling.ModularClassResolver; import org.jboss.modules.Module; import org.wildfly.clustering.ejb.bean.BeanDeploymentMarshallingContext; import org.wildfly.clustering.ejb.client.EJBProxyResolver; import org.wildfly.clustering.marshalling.jboss.DynamicClassTable; import org.wildfly.clustering.marshalling.jboss.DynamicExternalizerObjectTable; import org.wildfly.clustering.marshalling.jboss.JBossByteBufferMarshaller; import org.wildfly.clustering.marshalling.jboss.MarshallingConfigurationRepository; import org.wildfly.clustering.marshalling.jboss.SimpleMarshallingConfigurationRepository; import org.wildfly.clustering.marshalling.jboss.SimpleSerializabilityChecker; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; /** * Enumerates factory implementations for all supported bean marshallers. * @author Paul Ferraro */ public enum BeanMarshallerFactory implements Function<BeanDeploymentMarshallingContext, ByteBufferMarshaller> { JBOSS() { @Override public ByteBufferMarshaller apply(BeanDeploymentMarshallingContext context) { MarshallingConfigurationRepository repository = new SimpleMarshallingConfigurationRepository(MarshallingVersion.class, MarshallingVersion.CURRENT, context); return new JBossByteBufferMarshaller(repository, context.getModule().getClassLoader()); } }; enum MarshallingVersion implements Function<BeanDeploymentMarshallingContext, MarshallingConfiguration> { VERSION_1() { @SuppressWarnings("deprecation") @Override public MarshallingConfiguration apply(BeanDeploymentMarshallingContext context) { Module module = context.getModule(); MarshallingConfiguration config = new MarshallingConfiguration(); config.setClassResolver(ModularClassResolver.getInstance(module.getModuleLoader())); config.setSerializabilityChecker(new SimpleSerializabilityChecker(context.getBeanClasses())); config.setClassTable(new DynamicClassTable(module.getClassLoader())); config.setObjectTable(new org.wildfly.clustering.ejb.client.EJBProxyObjectTable()); return config; } }, VERSION_2() { @Override public MarshallingConfiguration apply(BeanDeploymentMarshallingContext context) { Module module = context.getModule(); MarshallingConfiguration config = new MarshallingConfiguration(); config.setClassResolver(ModularClassResolver.getInstance(module.getModuleLoader())); config.setSerializabilityChecker(new SimpleSerializabilityChecker(context.getBeanClasses())); config.setClassTable(new DynamicClassTable(module.getClassLoader())); config.setObjectResolver(new EJBProxyResolver()); config.setObjectTable(new DynamicExternalizerObjectTable(module.getClassLoader())); return config; } }, ; static final MarshallingVersion CURRENT = VERSION_2; } }
4,299
49.588235
168
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/ImmutableBeanGroup.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.BeanInstance; /** * Exposes the context of, and manages the lifecycle for, groups of beans. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface ImmutableBeanGroup<K, V extends BeanInstance<K>> extends AutoCloseable { /** * Returns the unique identifier of this bean group. * @return a unique identifier */ K getId(); /** * Indicates whether or not this bean group contains and bean instances. * @return true, if this bean group is empty, false otherwise */ boolean isEmpty(); /** * Returns the bean instance with the specified identifier. * @param id a bean instance identifier * @return the requested bean instance, or null, if no such bean instance exists. */ V getBeanInstance(K id); /** * Indicates that the caller is finished with the bean group, and that it should close any resources. */ @Override void close(); }
2,103
34.066667
105
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/SimpleBeanCreationMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.time.Instant; import java.time.temporal.ChronoUnit; /** * A simple {@link BeanCreationMetaData} implementation * @author Paul Ferraro * @param <K> the bean group identifier type */ public class SimpleBeanCreationMetaData<K> implements BeanCreationMetaData<K> { private final String name; private final K groupId; private final Instant creationTime; public SimpleBeanCreationMetaData(String name, K groupId) { this(name, groupId, Instant.now().truncatedTo(ChronoUnit.MILLIS)); } SimpleBeanCreationMetaData(String name, K groupId, Instant creationTime) { this.name = name; this.groupId = groupId; this.creationTime = creationTime; } @Override public String getName() { return this.name; } @Override public K getGroupId() { return this.groupId; } @Override public Instant getCreationTime() { return this.creationTime; } @Override public String toString() { StringBuilder builder = new StringBuilder(this.getClass().getSimpleName()).append(" { "); builder.append("name = ").append(this.name); builder.append(", group = ").append(this.groupId); builder.append(", created = ").append(this.creationTime); return builder.append(" }").toString(); } }
2,410
32.027397
97
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/CompositeBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import org.wildfly.clustering.ee.Remover; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.ejb.bean.BeanMetaData; /** * A {@link MutableBean} implementation composed from a {@link BeanMetaData} and a {@link BeanGroup}. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public class CompositeBean<K, V extends BeanInstance<K>> extends CompositeImmutableBean<K, V> implements MutableBean<K, V> { private final BeanMetaData<K> metaData; private final BeanGroup<K, V> group; private final Remover<K> remover; private final AtomicBoolean valid = new AtomicBoolean(true); public CompositeBean(K id, BeanMetaData<K> metaData, BeanGroup<K, V> group, Remover<K> remover) { super(id, group.getBeanInstance(id), metaData); this.metaData = metaData; this.group = group; this.remover = remover; } @Override public BeanMetaData<K> getMetaData() { return this.metaData; } @Override public void setInstance(V instance) { this.group.addBeanInstance(instance); } @Override public boolean isValid() { return this.valid.get(); } @Override public void remove(Consumer<V> removeTask) { // Ensure we only close group once if (this.valid.compareAndSet(true, false)) { try { K id = this.getId(); V instance = this.group.removeBeanInstance(id); this.remover.remove(id); if (instance != null) { removeTask.accept(instance); } } finally { this.group.close(); } } } @Override public void close() { if (this.valid.compareAndSet(true, false)) { this.group.close(); } } }
3,040
32.417582
124
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanMetaDataFactoryConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.BeanExpiration; /** * Encapsulates the configuration of a {@link BeanMetaDataFactory}. * @author Paul Ferraro */ public interface BeanMetaDataFactoryConfiguration { String getBeanName(); BeanExpiration getExpiration(); }
1,344
37.428571
70
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanCreationMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.time.Instant; /** * Describes the metadata of a cached bean that does not change between invocations/transactions. * @author Paul Ferraro * @param <K> the bean group identifier type */ public interface BeanCreationMetaData<K> { String getName(); K getGroupId(); Instant getCreationTime(); }
1,392
36.648649
97
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/DefaultImmutableBeanGroup.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.util.Map; import org.wildfly.clustering.ejb.bean.BeanInstance; /** * A default {@link ImmutableBeanGroup} implementation based on a map of bean instances. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public class DefaultImmutableBeanGroup<K, V extends BeanInstance<K>> implements ImmutableBeanGroup<K, V> { private final K id; private final Map<K, V> instances; private final Runnable closeTask; public DefaultImmutableBeanGroup(K id, Map<K, V> instances, Runnable closeTask) { this.id = id; this.instances = instances; this.closeTask = closeTask; } @Override public K getId() { return this.id; } @Override public boolean isEmpty() { return this.instances.isEmpty(); } @Override public V getBeanInstance(K id) { return this.instances.get(id); } @Override public void close() { this.closeTask.run(); } @Override public String toString() { return String.format("%s { %s -> %s }", this.getClass().getSimpleName(), this.id, this.instances.keySet()); } }
2,247
30.222222
115
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/CompositeImmutableBeanFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.ejb.bean.ImmutableBean; import org.wildfly.clustering.ejb.bean.ImmutableBeanMetaData; /** * A {@link ImmutableBeanFactory} implementation that creates {@link CompositeImmutableBean} instances. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type * @param <M> the bean metadata value type */ public class CompositeImmutableBeanFactory<K, V extends BeanInstance<K>, M> implements ImmutableBeanFactory<K, V, M> { private final ImmutableBeanMetaDataFactory<K, M> metaDataFactory; private final ImmutableBeanGroupManager<K, V> groupManager; public CompositeImmutableBeanFactory(ImmutableBeanMetaDataFactory<K, M> metaDataFactory, ImmutableBeanGroupManager<K, V> groupManager) { this.metaDataFactory = metaDataFactory; this.groupManager = groupManager; } @Override public ImmutableBeanMetaDataFactory<K, M> getMetaDataFactory() { return this.metaDataFactory; } @Override public ImmutableBeanGroupManager<K, V> getBeanGroupManager() { return this.groupManager; } @Override public ImmutableBean<K, V> createImmutableBean(K id, ImmutableBeanMetaData<K> metaData, ImmutableBeanGroup<K, V> group) { return new CompositeImmutableBean<>(id, group.getBeanInstance(id), metaData); } }
2,473
39.557377
140
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/ImmutableBeanFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ee.Locator; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.ejb.bean.ImmutableBean; import org.wildfly.clustering.ejb.bean.ImmutableBeanMetaData; /** * A factory for creating {@link ImmutableBean} instances from an {@link ImmutableBeanMetaDataFactory} and an {@link ImmutableBeanGroupManager}. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type * @param <M> the bean metadata value type */ public interface ImmutableBeanFactory<K, V extends BeanInstance<K>, M> extends Locator<K, M> { ImmutableBeanMetaDataFactory<K, M> getMetaDataFactory(); ImmutableBeanGroupManager<K, V> getBeanGroupManager(); @Override default M findValue(K id) { return this.getMetaDataFactory().findValue(id); } @Override default M tryValue(K id) { return this.getMetaDataFactory().tryValue(id); } default ImmutableBean<K, V> createImmutableBean(K id, M value) { ImmutableBeanMetaData<K> metaData = this.getMetaDataFactory().createImmutableBeanMetaData(id, value); ImmutableBeanGroup<K, V> group = this.getBeanGroupManager().getImmutableBeanGroup(metaData.getGroupId()); return this.createImmutableBean(id, metaData, group); } ImmutableBean<K, V> createImmutableBean(K id, ImmutableBeanMetaData<K> metaData, ImmutableBeanGroup<K, V> group); }
2,494
41.288136
144
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/DefaultBeanGroupManagerConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import java.util.Map; import org.wildfly.clustering.ee.Creator; import org.wildfly.clustering.ee.MutatorFactory; import org.wildfly.clustering.ee.Remover; import org.wildfly.clustering.ee.cache.CacheProperties; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.marshalling.spi.MarshalledValue; import org.wildfly.clustering.marshalling.spi.MarshalledValueFactory; /** * Encapsulates the configuration of a {@link DefaultBeanGroupManager}. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type * @param <C> the marshalled value context type */ public interface DefaultBeanGroupManagerConfiguration<K, V extends BeanInstance<K>, C> { Creator<K, MarshalledValue<Map<K, V>, C>, MarshalledValue<Map<K, V>, C>> getCreator(); Remover<K> getRemover(); MutatorFactory<K, MarshalledValue<Map<K, V>, C>> getMutatorFactory(); CacheProperties getCacheProperties(); MarshalledValueFactory<C> getMarshalledValueFactory(); }
2,085
41.571429
90
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanManagerFactoryConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.BeanConfiguration; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.ejb.bean.BeanPassivationConfiguration; import org.wildfly.clustering.group.Group; /** * Encapsulates the configuration of a {@link org.wildfly.clustering.ejb.bean.BeanManagerFactory} implementation. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface BeanManagerFactoryConfiguration<K, V extends BeanInstance<K>> { BeanGroupManager<K, V> getBeanGroupManager(); BeanConfiguration getBeanConfiguration(); BeanPassivationConfiguration getPassivationConfiguration(); Group getGroup(); }
1,783
41.47619
113
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/CompositeImmutableBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ejb.bean.BeanInstance; import org.wildfly.clustering.ejb.bean.ImmutableBean; import org.wildfly.clustering.ejb.bean.ImmutableBeanMetaData; /** * A {@link ImmutableBean} implementation composed from a {@link BeanInstance} and an {@link ImmutableBeanMetaData}. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public class CompositeImmutableBean<K, V extends BeanInstance<K>> implements ImmutableBean<K, V> { private final K id; private final V instance; private final ImmutableBeanMetaData<K> metaData; public CompositeImmutableBean(K id, V instance, ImmutableBeanMetaData<K> metaData) { this.id = id; this.instance = instance; this.metaData = metaData; } @Override public K getId() { return this.id; } @Override public V getInstance() { return this.instance; } @Override public ImmutableBeanMetaData<K> getMetaData() { return this.metaData; } }
2,113
33.096774
116
java
null
wildfly-main/clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/BeanGroupKey.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.cache.bean; import org.wildfly.clustering.ee.Key; /** * The key used to cache a group of beans. * @author Paul Ferraro * @param <K> the bean group identifier type */ public interface BeanGroupKey<K> extends Key<K> { }
1,283
36.764706
70
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/ServiceLoaderTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan; import java.util.ServiceLoader; import org.infinispan.persistence.keymappers.TwoWayKey2StringMapper; import org.infinispan.protostream.SerializationContextInitializer; import org.junit.Test; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.server.service.DistributedCacheServiceConfiguratorProvider; import org.wildfly.clustering.server.service.IdentityCacheServiceConfiguratorProvider; import org.wildfly.clustering.server.service.LocalCacheServiceConfiguratorProvider; /** * Validates loading of services. * * @author Paul Ferraro */ public class ServiceLoaderTestCase { private static <T> void load(Class<T> targetClass) { System.out.println(targetClass.getName() + ":"); ServiceLoader.load(targetClass, ServiceLoaderTestCase.class.getClassLoader()).forEach(object -> System.out.println("\t" + object.getClass().getName())); } @SuppressWarnings("deprecation") @Test public void load() { load(Externalizer.class); load(org.wildfly.clustering.ejb.bean.LegacyBeanManagementProviderFactory.class); load(DistributedCacheServiceConfiguratorProvider.class); load(LocalCacheServiceConfiguratorProvider.class); load(IdentityCacheServiceConfiguratorProvider.class); load(TwoWayKey2StringMapper.class); load(SerializationContextInitializer.class); } }
2,457
40.661017
160
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/network/ClientMappingMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.network; import java.net.InetAddress; import org.jboss.as.network.ClientMapping; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Unit test for {@link ClientMappingMarshaller}. * @author Paul Ferraro */ public class ClientMappingMarshallerTestCase { @Test public void test() throws Exception { Tester<ClientMapping> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new ClientMapping(InetAddress.getByName("0.0.0.0"), 0, InetAddress.getLoopbackAddress().getHostName(), 8080), ClientMappingMarshallerTestCase::assertEquals); tester.test(new ClientMapping(InetAddress.getLocalHost(), 16, InetAddress.getLocalHost().getHostName(), Short.MAX_VALUE), ClientMappingMarshallerTestCase::assertEquals); } static void assertEquals(ClientMapping mapping1, ClientMapping mapping2) { Assert.assertEquals(mapping1.getSourceNetworkAddress(), mapping2.getSourceNetworkAddress()); Assert.assertEquals(mapping1.getSourceNetworkMaskBits(), mapping2.getSourceNetworkMaskBits()); Assert.assertEquals(mapping1.getDestinationAddress(), mapping2.getDestinationAddress()); Assert.assertEquals(mapping1.getDestinationPort(), mapping2.getDestinationPort()); } }
2,445
45.150943
177
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/timer/MockScheduleTimerOperationProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.time.Instant; import java.util.Optional; import java.util.function.UnaryOperator; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.ejb.timer.ImmutableScheduleExpression; import org.wildfly.clustering.ejb.timer.ScheduleTimerOperationProvider; /** * @author Paul Ferraro */ @MetaInfServices(ScheduleTimerOperationProvider.class) public class MockScheduleTimerOperationProvider implements ScheduleTimerOperationProvider { @Override public UnaryOperator<Instant> createOperator(ImmutableScheduleExpression expression) { return instant -> Optional.ofNullable(instant).orElse(Instant.now()); } }
1,722
38.159091
91
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/timer/TimerKeyMapperTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.util.UUID; import org.junit.Test; import org.wildfly.clustering.ejb.infinispan.KeyMapper; import org.wildfly.clustering.infinispan.persistence.KeyMapperTester; /** * Validates {@link org.infinispan.persistence.keymappers.TwoWayKey2StringMapper} implementations for keys used by distributed timer service. * @author Paul Ferraro */ public class TimerKeyMapperTestCase { @Test public void test() throws NoSuchMethodException, SecurityException { KeyMapperTester tester = new KeyMapperTester(new KeyMapper()); UUID id = UUID.randomUUID(); tester.test(new TimerCreationMetaDataKey<>(id)); tester.test(new TimerAccessMetaDataKey<>(id)); tester.test(new TimerIndexKey(new TimerIndex(this.getClass().getDeclaredMethod("test"), 0))); tester.test(new TimerIndexKey(new TimerIndex(this.getClass().getDeclaredMethod("test"), 1))); tester.test(new TimerIndexKey(new TimerIndex(this.getClass().getDeclaredMethod("ejbTimeout", Object.class), 0))); tester.test(new TimerIndexKey(new TimerIndex(this.getClass().getDeclaredMethod("ejbTimeout", Object.class), 2))); } void ejbTimeout(Object timer) { } }
2,267
42.615385
141
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/timer/IntervalTimerCreationMetaDataEntryMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.io.IOException; import java.time.Duration; import java.time.Instant; import java.util.UUID; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.ejb.timer.IntervalTimerConfiguration; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; import org.wildfly.clustering.marshalling.protostream.TestProtoStreamByteBufferMarshaller; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledValueFactory; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.marshalling.spi.MarshalledValue; /** * @author Paul Ferraro */ public class IntervalTimerCreationMetaDataEntryMarshallerTestCase { @Test public void test() throws IOException { MarshalledValue<UUID, ByteBufferMarshaller> context = new ByteBufferMarshalledValueFactory(TestProtoStreamByteBufferMarshaller.INSTANCE).createMarshalledValue(UUID.randomUUID()); Tester<IntervalTimerCreationMetaDataEntry<MarshalledValue<UUID, ByteBufferMarshaller>>> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new IntervalTimerCreationMetaDataEntry<>(context, new IntervalTimerConfiguration() { @Override public Instant getStart() { return Instant.now(); } }), IntervalTimerCreationMetaDataEntryMarshallerTestCase::assertEquals); tester.test(new IntervalTimerCreationMetaDataEntry<>(context, new IntervalTimerConfiguration() { @Override public Instant getStart() { return Instant.now(); } @Override public Duration getInterval() { return Duration.ofMinutes(1); } }), IntervalTimerCreationMetaDataEntryMarshallerTestCase::assertEquals); } private static <V> void assertEquals(IntervalTimerCreationMetaDataEntry<V> entry1, IntervalTimerCreationMetaDataEntry<V> entry2) { Assert.assertEquals(entry1.getContext(), entry2.getContext()); Assert.assertEquals(entry1.getInterval(), entry2.getInterval()); Assert.assertEquals(entry1.getStart(), entry2.getStart()); Assert.assertEquals(entry1.getTimeoutMatcher(), entry2.getTimeoutMatcher()); Assert.assertSame(entry1.getType(), entry2.getType()); } }
3,465
44.605263
186
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/timer/TimerIndexKeyMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.io.IOException; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * @author Paul Ferraro */ public class TimerIndexKeyMarshallerTestCase { @Test public void test() throws IOException, NoSuchMethodException, SecurityException { Tester<TimerIndexKey> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new TimerIndexKey(new TimerIndex(this.getClass().getDeclaredMethod("test"), 0))); tester.test(new TimerIndexKey(new TimerIndex(this.getClass().getDeclaredMethod("ejbTimeout", Object.class), 0))); } void ejbTimeout(Object timer) { } }
1,801
38.173913
121
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/timer/TimerAccessMetaDataKeyMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.io.IOException; import java.util.UUID; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * @author Paul Ferraro */ public class TimerAccessMetaDataKeyMarshallerTestCase { @Test public void test() throws IOException { Tester<TimerAccessMetaDataKey<UUID>> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new TimerAccessMetaDataKey<>(UUID.randomUUID())); } }
1,609
36.44186
103
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/timer/TimerCreationMetaDataKeyMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.io.IOException; import java.util.UUID; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * @author Paul Ferraro */ public class TimerCreationMetaDataKeyMarshallerTestCase { @Test public void test() throws IOException { Tester<TimerCreationMetaDataKey<UUID>> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new TimerCreationMetaDataKey<>(UUID.randomUUID())); } }
1,615
36.581395
105
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/timer/ScheduleTimerCreationMetaDataEntryMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.io.IOException; import java.time.Duration; import java.time.Instant; import java.time.ZoneId; import java.util.UUID; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.ejb.timer.ImmutableScheduleExpression; import org.wildfly.clustering.ejb.timer.ScheduleTimerConfiguration; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; import org.wildfly.clustering.marshalling.protostream.TestProtoStreamByteBufferMarshaller; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledValueFactory; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.marshalling.spi.MarshalledValue; /** * @author Paul Ferraro */ public class ScheduleTimerCreationMetaDataEntryMarshallerTestCase { @Test public void test() throws IOException, NoSuchMethodException { MarshalledValue<UUID, ByteBufferMarshaller> context = new ByteBufferMarshalledValueFactory(TestProtoStreamByteBufferMarshaller.INSTANCE).createMarshalledValue(UUID.randomUUID()); Tester<ScheduleTimerCreationMetaDataEntry<MarshalledValue<UUID, ByteBufferMarshaller>>> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new ScheduleTimerCreationMetaDataEntry<>(context, new ScheduleTimerConfiguration() { @Override public ImmutableScheduleExpression getScheduleExpression() { return new ImmutableScheduleExpressionBuilder().build(); } }, null), ScheduleTimerCreationMetaDataEntryMarshallerTestCase::assertEquals); tester.test(new ScheduleTimerCreationMetaDataEntry<>(context, new ScheduleTimerConfiguration() { @Override public ImmutableScheduleExpression getScheduleExpression() { return new ImmutableScheduleExpressionBuilder().start(Instant.now()).end(Instant.now().plus(Duration.ofHours(1))).year("1970").month("1").dayOfMonth("1").dayOfWeek("1").zone(ZoneId.of("GMT")).hour("0").minute("0").second("0").build(); } }, ScheduleTimerCreationMetaDataEntryMarshallerTestCase.class.getDeclaredMethod("test")), ScheduleTimerCreationMetaDataEntryMarshallerTestCase::assertEquals); tester.test(new ScheduleTimerCreationMetaDataEntry<>(context, new ScheduleTimerConfiguration() { @Override public ImmutableScheduleExpression getScheduleExpression() { return new ImmutableScheduleExpressionBuilder().start(Instant.now()).end(Instant.now().plus(Duration.ofHours(1))).year("1970").month("JAN").dayOfMonth("1").dayOfWeek("TUES").zone(ZoneId.of("America/New_York")).hour("0").minute("0").second("0").build(); } }, ScheduleTimerCreationMetaDataEntryMarshallerTestCase.class.getDeclaredMethod("ejbTimeout", Object.class)), ScheduleTimerCreationMetaDataEntryMarshallerTestCase::assertEquals); } void ejbTimeout(Object timer) { } private static <V> void assertEquals(ScheduleTimerCreationMetaDataEntry<V> entry1, ScheduleTimerCreationMetaDataEntry<V> entry2) { Assert.assertEquals(entry1.getContext(), entry2.getContext()); Assert.assertEquals(entry1.getStart(), entry2.getStart()); Assert.assertEquals(entry1.getTimeoutMatcher(), entry2.getTimeoutMatcher()); Assert.assertSame(entry1.getType(), entry2.getType()); Assert.assertEquals(entry1.getScheduleExpression().getStart(), entry2.getScheduleExpression().getStart()); Assert.assertEquals(entry1.getScheduleExpression().getEnd(), entry2.getScheduleExpression().getEnd()); Assert.assertEquals(entry1.getScheduleExpression().getYear(), entry2.getScheduleExpression().getYear()); Assert.assertEquals(entry1.getScheduleExpression().getMonth(), entry2.getScheduleExpression().getMonth()); Assert.assertEquals(entry1.getScheduleExpression().getDayOfMonth(), entry2.getScheduleExpression().getDayOfMonth()); Assert.assertEquals(entry1.getScheduleExpression().getDayOfWeek(), entry2.getScheduleExpression().getDayOfWeek()); Assert.assertEquals(entry1.getScheduleExpression().getZone(), entry2.getScheduleExpression().getZone()); Assert.assertEquals(entry1.getScheduleExpression().getHour(), entry2.getScheduleExpression().getHour()); Assert.assertEquals(entry1.getScheduleExpression().getMinute(), entry2.getScheduleExpression().getMinute()); Assert.assertEquals(entry1.getScheduleExpression().getSecond(), entry2.getScheduleExpression().getSecond()); } }
5,663
61.241758
268
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/bean/InfinispanBeanAccessMetaDataKeyTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.bean; import java.io.IOException; import java.util.UUID; import org.jboss.ejb.client.SessionID; import org.jboss.ejb.client.UUIDSessionID; import org.junit.Test; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Unit test for {@link InfinispanBeanAccessMetaDataKey} marshalling. * @author Paul Ferraro */ public class InfinispanBeanAccessMetaDataKeyTestCase { @Test public void test() throws IOException { InfinispanBeanAccessMetaDataKey<SessionID> key = new InfinispanBeanAccessMetaDataKey<>(new UUIDSessionID(UUID.randomUUID())); ProtoStreamTesterFactory.INSTANCE.createTester().test(key); } }
1,738
36.804348
133
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/bean/InfinispanBeanCreationMetaDataKeyTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.bean; import java.io.IOException; import java.util.UUID; import org.jboss.ejb.client.SessionID; import org.jboss.ejb.client.UUIDSessionID; import org.junit.Test; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Unit test for {@link InfinispanBeanCreationMetaDataKey} marshalling. * @author Paul Ferraro */ public class InfinispanBeanCreationMetaDataKeyTestCase { @Test public void test() throws IOException { InfinispanBeanCreationMetaDataKey<SessionID> key = new InfinispanBeanCreationMetaDataKey<>(new UUIDSessionID(UUID.randomUUID())); ProtoStreamTesterFactory.INSTANCE.createTester().test(key); } }
1,746
36.978261
137
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/bean/BeanKeyMapperTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.bean; import java.util.UUID; import org.jboss.ejb.client.SessionID; import org.jboss.ejb.client.UUIDSessionID; import org.junit.Test; import org.wildfly.clustering.ejb.infinispan.KeyMapper; import org.wildfly.clustering.infinispan.persistence.KeyMapperTester; /** * Validates {@link org.infinispan.persistence.keymappers.TwoWayKey2StringMapper} instances for bean-related keys. * @author Paul Ferraro */ public class BeanKeyMapperTestCase { @Test public void test() { KeyMapperTester tester = new KeyMapperTester(new KeyMapper()); SessionID id = new UUIDSessionID(UUID.randomUUID()); tester.test(new InfinispanBeanCreationMetaDataKey<>(id)); tester.test(new InfinispanBeanAccessMetaDataKey<>(id)); tester.test(new InfinispanBeanGroupKey<>(id)); } }
1,878
38.145833
114
java
null
wildfly-main/clustering/ejb/infinispan/src/test/java/org/wildfly/clustering/ejb/infinispan/bean/InfinispanBeanGroupKeyTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.bean; import java.io.IOException; import java.util.UUID; import org.jboss.ejb.client.SessionID; import org.jboss.ejb.client.UUIDSessionID; import org.junit.Test; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Unit test for {@link InfinispanBeanGroupKey} marshalling. * @author Paul Ferraro */ public class InfinispanBeanGroupKeyTestCase { @Test public void test() throws IOException { InfinispanBeanGroupKey<SessionID> key = new InfinispanBeanGroupKey<>(new UUIDSessionID(UUID.randomUUID())); ProtoStreamTesterFactory.INSTANCE.createTester().test(key); } }
1,702
36.021739
115
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/EJBSerializationContextInitializerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan; import org.infinispan.protostream.SerializationContextInitializer; import org.wildfly.clustering.ejb.cache.bean.BeanSerializationContextInitializer; import org.wildfly.clustering.ejb.client.EJBClientSerializationContextInitializer; import org.wildfly.clustering.ejb.infinispan.bean.InfinispanBeanSerializationContextInitializer; import org.wildfly.clustering.ejb.infinispan.network.NetworkEJBSerializationContextInitializer; import org.wildfly.clustering.ejb.infinispan.network.NetworkMarshallingProvider; import org.wildfly.clustering.ejb.infinispan.timer.TimerSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.ProviderSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.SerializationContextInitializerProvider; /** * {@link SerializationContextInitializer} provider for this module. * @author Paul Ferraro */ public enum EJBSerializationContextInitializerProvider implements SerializationContextInitializerProvider { NETWORK(new ProviderSerializationContextInitializer<>("org.jboss.as.network.proto", NetworkMarshallingProvider.class)), INFINISPAN_NETWORK(new NetworkEJBSerializationContextInitializer()), EJB_CLIENT(new EJBClientSerializationContextInitializer()), BEAN(new BeanSerializationContextInitializer()), INFINISPAN(new InfinispanBeanSerializationContextInitializer()), TIMER(new TimerSerializationContextInitializer()), ; private final SerializationContextInitializer initializer; EJBSerializationContextInitializerProvider(SerializationContextInitializer initializer) { this.initializer = initializer; } @Override public SerializationContextInitializer getInitializer() { return this.initializer; } }
2,835
46.266667
123
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/KeyMapper.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan; import org.infinispan.persistence.keymappers.TwoWayKey2StringMapper; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.infinispan.persistence.DynamicKeyFormatMapper; /** * {@link TwoWayKey2StringMapper} for Jakarta Enterprise Beans cache keys. * @author Paul Ferraro */ @MetaInfServices(TwoWayKey2StringMapper.class) public class KeyMapper extends DynamicKeyFormatMapper { public KeyMapper() { super(KeyMapper.class.getClassLoader()); } }
1,548
37.725
76
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/EJBSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan; import org.infinispan.protostream.SerializationContextInitializer; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.protostream.CompositeSerializationContextInitializer; /** * {@link SerializationContextInitializer} service for this module * @author Paul Ferraro */ @MetaInfServices(SerializationContextInitializer.class) public class EJBSerializationContextInitializer extends CompositeSerializationContextInitializer { public EJBSerializationContextInitializer() { super(EJBSerializationContextInitializerProvider.class); } }
1,650
40.275
98
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/logging/InfinispanEjbLogger.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.logging; import static org.jboss.logging.Logger.Level.WARN; import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.LogMessage; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageLogger; /** * Logger for this module. * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> * @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a> */ @MessageLogger(projectCode = "WFLYCLEJBINF", length = 4) public interface InfinispanEjbLogger extends BasicLogger { String ROOT_LOGGER_CATEGORY = "org.wildfly.clustering.ejb.infinispan"; /** * A logger with the category of the default clustering package. */ InfinispanEjbLogger ROOT_LOGGER = Logger.getMessageLogger(InfinispanEjbLogger.class, ROOT_LOGGER_CATEGORY); // @LogMessage(level = WARN) // @Message(id = 1, value = "Failed to passivate stateful session bean %s") // void failedToPassivateBean(@Cause Throwable cause, Object id); // @LogMessage(level = WARN) // @Message(id = 2, value = "Failed to passivate stateful session bean group %s") // void failedToPassivateBeanGroup(@Cause Throwable cause, Object id); @LogMessage(level = WARN) @Message(id = 3, value = "Failed to expire stateful session bean %s") void failedToExpireBean(@Cause Throwable cause, Object id); // @Message(id = 4, value = "Failed to deserialize %s") // IllegalStateException deserializationFailure(@Cause Throwable cause, Object key); // @LogMessage(level = DEBUG) // @Message(id = 5, value = "Failed to cancel expiration/passivation of bean %s on primary owner.") // void failedToCancelBean(@Cause Throwable cause, Object beanId); // @LogMessage(level = DEBUG) // @Message(id = 6, value = "Failed to schedule expiration/passivation of bean %s on primary owner.") // void failedToScheduleBean(@Cause Throwable cause, Object beanId); // @LogMessage(level = WARN) // @Message(id = 8, value = "Stateful session bean %s refers to an invalid bean group %s") // void invalidBeanGroup(Object beanId, Object groupId); // @LogMessage(level = WARN) // @Message(id = 9, value = "Disabling eviction for cache '%s'. SFSB passivation should be configured via the associated Jakarta Enterprise Beans subsystem passivation-store.") // void evictionDisabled(String cacheName); @LogMessage(level = WARN) @Message(id = 10, value = "Disabling expiration for '%s'. SFSB expiration should be configured per \u00A74.3.11 of the Jakarta Enterprise Beans specification.") void expirationDisabled(String cacheName); }
3,758
44.289157
179
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/remote/InfinispanClientMappingsRegistryProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.remote; import java.util.List; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.ServiceNameFactory; import org.jboss.as.network.ClientMapping; import org.wildfly.clustering.ejb.infinispan.network.ClientMappingsRegistryEntryServiceConfigurator; import org.wildfly.clustering.ejb.remote.ClientMappingsRegistryProvider; import org.wildfly.clustering.infinispan.service.CacheServiceConfigurator; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.TemplateConfigurationServiceConfigurator; import org.wildfly.clustering.server.service.ProvidedCacheServiceConfigurator; import org.wildfly.clustering.server.service.group.DistributedCacheGroupServiceConfiguratorProvider; import org.wildfly.clustering.server.service.registry.DistributedRegistryServiceConfiguratorProvider; import org.wildfly.clustering.service.SupplierDependency; /** * The non-legacy version of the client mappings registry provider, used when the distributable-ejb subsystem is present. * * @author Paul Ferraro * @author Richard Achmatowicz */ public class InfinispanClientMappingsRegistryProvider implements ClientMappingsRegistryProvider { private final String containerName ; private final String cacheName; /** * Creates an instance of the Infinispan-based client mappings registry provider, for local or distribute use, based on a cache-service abstraction. * * @param containerName name of the existing cache container to use, must be defined in the Infinispan subsystem. * @param cacheName name of the existing cache configuration to use, must be defined in the Infinispan subsystem. */ public InfinispanClientMappingsRegistryProvider(final String containerName, final String cacheName) { this.containerName = containerName; this.cacheName = cacheName; } @Override public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String connectorName, SupplierDependency<List<ClientMapping>> clientMappings) { CapabilityServiceConfigurator configurationConfigurator = new TemplateConfigurationServiceConfigurator(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CONFIGURATION.getName()).append(this.containerName, connectorName), this.containerName, connectorName, this.cacheName); CapabilityServiceConfigurator cacheConfigurator = new CacheServiceConfigurator<>(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CACHE.getName()).append(this.containerName, connectorName), this.containerName, connectorName); CapabilityServiceConfigurator registryEntryConfigurator = new ClientMappingsRegistryEntryServiceConfigurator(this.containerName, connectorName, clientMappings); CapabilityServiceConfigurator groupConfigurator = new ProvidedCacheServiceConfigurator<>(DistributedCacheGroupServiceConfiguratorProvider.class, this.containerName, connectorName); CapabilityServiceConfigurator registryConfigurator = new ProvidedCacheServiceConfigurator<>(DistributedRegistryServiceConfiguratorProvider.class, this.containerName, connectorName); return List.of(configurationConfigurator, cacheConfigurator, registryEntryConfigurator, registryConfigurator, groupConfigurator); } }
4,403
60.166667
293
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/remote/LegacyInfinispanClientMappingsRegistryProviderFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.remote; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.ejb.remote.ClientMappingsRegistryProvider; import org.wildfly.clustering.ejb.remote.LegacyClientMappingsRegistryProviderFactory; /** * Factory for creating legacy version of the InfinispanClientMappingsRegistryProvider * * @author Richard Achmatowicz */ @Deprecated @MetaInfServices(LegacyClientMappingsRegistryProviderFactory.class) public class LegacyInfinispanClientMappingsRegistryProviderFactory implements LegacyClientMappingsRegistryProviderFactory { @Override public ClientMappingsRegistryProvider createClientMappingsRegistryProvider(String clusterName) { // need to create and return a configured client mappings registry factory return new LegacyInfinispanClientMappingsRegistryProvider(clusterName); } }
1,895
42.090909
123
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/remote/LegacyInfinispanClientMappingsRegistryProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.remote; import java.util.List; import java.util.function.Consumer; import org.infinispan.commons.configuration.attributes.AttributeSet; import org.infinispan.configuration.cache.CacheMode; import org.infinispan.configuration.cache.ClusteringConfiguration; import org.infinispan.configuration.cache.ClusteringConfigurationBuilder; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.StateTransferConfiguration; import org.infinispan.configuration.cache.StateTransferConfigurationBuilder; import org.infinispan.configuration.cache.StorageType; import org.infinispan.eviction.EvictionStrategy; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.ServiceNameFactory; import org.jboss.as.network.ClientMapping; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.ejb.infinispan.network.ClientMappingsRegistryEntryServiceConfigurator; import org.wildfly.clustering.ejb.remote.ClientMappingsRegistryProvider; import org.wildfly.clustering.infinispan.configuration.ConfigurationBuilderAttributesAccessor; import org.wildfly.clustering.infinispan.container.DataContainerConfigurationBuilder; import org.wildfly.clustering.infinispan.service.CacheServiceConfigurator; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.TemplateConfigurationServiceConfigurator; import org.wildfly.clustering.server.service.ProvidedCacheServiceConfigurator; import org.wildfly.clustering.server.service.group.DistributedCacheGroupServiceConfiguratorProvider; import org.wildfly.clustering.server.service.registry.DistributedRegistryServiceConfiguratorProvider; import org.wildfly.clustering.service.SupplierDependency; /** * The legacy version of the client mappings registry provider, used when no distributable-ejb subsystem is present. * * @author Paul Ferraro */ @Deprecated @MetaInfServices(ClientMappingsRegistryProvider.class) public class LegacyInfinispanClientMappingsRegistryProvider implements ClientMappingsRegistryProvider, Consumer<ConfigurationBuilder> { private final String containerName; public LegacyInfinispanClientMappingsRegistryProvider(final String containerName) { this.containerName = containerName; } @Override public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String connectorName, SupplierDependency<List<ClientMapping>> clientMappings) { CapabilityServiceConfigurator configurationConfigurator = new TemplateConfigurationServiceConfigurator(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CONFIGURATION.getName()).append(this.containerName, connectorName), this.containerName, connectorName, null, this); CapabilityServiceConfigurator cacheConfigurator = new CacheServiceConfigurator<>(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CACHE.getName()).append(this.containerName, connectorName), this.containerName, connectorName); CapabilityServiceConfigurator registryEntryConfigurator = new ClientMappingsRegistryEntryServiceConfigurator(this.containerName, connectorName, clientMappings); CapabilityServiceConfigurator registryConfigurator = new ProvidedCacheServiceConfigurator<>(DistributedRegistryServiceConfiguratorProvider.class, this.containerName, connectorName); CapabilityServiceConfigurator groupConfigurator = new ProvidedCacheServiceConfigurator<>(DistributedCacheGroupServiceConfiguratorProvider.class, this.containerName, connectorName); return List.of(configurationConfigurator, cacheConfigurator, registryEntryConfigurator, registryConfigurator, groupConfigurator); } @Override public void accept(ConfigurationBuilder builder) { ClusteringConfigurationBuilder clustering = builder.clustering(); CacheMode mode = clustering.cacheMode(); clustering.cacheMode(mode.needsStateTransfer() ? CacheMode.REPL_SYNC : CacheMode.LOCAL); clustering.l1().disable(); // Workaround for ISPN-8722 AttributeSet attributes = ConfigurationBuilderAttributesAccessor.INSTANCE.apply(clustering); attributes.attribute(ClusteringConfiguration.BIAS_ACQUISITION).reset(); attributes.attribute(ClusteringConfiguration.BIAS_LIFESPAN).reset(); attributes.attribute(ClusteringConfiguration.INVALIDATION_BATCH_SIZE).reset(); // Ensure we use the default data container builder.addModule(DataContainerConfigurationBuilder.class).evictable(null); // Disable expiration builder.expiration().lifespan(-1).maxIdle(-1); // Disable eviction builder.memory().storage(StorageType.HEAP).maxCount(-1).whenFull(EvictionStrategy.NONE); builder.persistence().clearStores(); StateTransferConfigurationBuilder stateTransfer = clustering.stateTransfer().fetchInMemoryState(mode.needsStateTransfer()); attributes = ConfigurationBuilderAttributesAccessor.INSTANCE.apply(stateTransfer); attributes.attribute(StateTransferConfiguration.AWAIT_INITIAL_TRANSFER).reset(); attributes.attribute(StateTransferConfiguration.TIMEOUT).reset(); } }
6,285
60.627451
289
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/network/ClientMappingMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.network; import java.io.IOException; import java.net.Inet4Address; import java.net.InetAddress; import org.infinispan.protostream.descriptors.WireType; import org.jboss.as.network.ClientMapping; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.common.net.Inet; /** * ProtoStream marshaller for a {@link ClientMapping}. * @author Paul Ferraro */ public class ClientMappingMarshaller implements ProtoStreamMarshaller<ClientMapping> { private static final InetAddress DEFAULT_SOURCE_ADDRESS = (InetAddress.getLoopbackAddress() instanceof Inet4Address) ? Inet.INET4_ANY : Inet.INET6_ANY; private static final int DEFAULT_SOURCE_MASK = 0; private static final String DEFAULT_DESTINATION_ADDRESS = Inet.toURLString(InetAddress.getLoopbackAddress(), true); private static final int DEFAULT_DESINATION_PORT = 8080; private static final int SOURCE_ADDRESS_INDEX = 1; private static final int SOURCE_MASK_INDEX = 2; private static final int DESTINATION_ADDRESS_INDEX = 3; private static final int DESTINATION_PORT_INDEX = 4; @Override public ClientMapping readFrom(ProtoStreamReader reader) throws IOException { InetAddress sourceAddress = DEFAULT_SOURCE_ADDRESS; int sourceMask = DEFAULT_SOURCE_MASK; String destinationAddress = DEFAULT_DESTINATION_ADDRESS; int destinationPort = DEFAULT_DESINATION_PORT; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case SOURCE_ADDRESS_INDEX: sourceAddress = reader.readObject(InetAddress.class); break; case SOURCE_MASK_INDEX: sourceMask = reader.readUInt32(); break; case DESTINATION_ADDRESS_INDEX: destinationAddress = reader.readString(); break; case DESTINATION_PORT_INDEX: destinationPort = reader.readUInt32(); break; default: reader.skipField(tag); } } return new ClientMapping(sourceAddress, sourceMask, destinationAddress, destinationPort); } @Override public void writeTo(ProtoStreamWriter writer, ClientMapping mapping) throws IOException { InetAddress address = mapping.getSourceNetworkAddress(); if (!address.equals(DEFAULT_SOURCE_ADDRESS)) { writer.writeObject(SOURCE_ADDRESS_INDEX, address); } int sourceNetworkMask = mapping.getSourceNetworkMaskBits(); if (sourceNetworkMask != DEFAULT_SOURCE_MASK) { writer.writeUInt32(SOURCE_MASK_INDEX, sourceNetworkMask); } String destinationAddress = mapping.getDestinationAddress(); if (!destinationAddress.equals(DEFAULT_DESTINATION_ADDRESS)) { writer.writeString(DESTINATION_ADDRESS_INDEX, mapping.getDestinationAddress()); } int destinationPort = mapping.getDestinationPort(); if (destinationPort != DEFAULT_DESINATION_PORT) { writer.writeUInt32(DESTINATION_PORT_INDEX, destinationPort); } } @Override public Class<? extends ClientMapping> getJavaClass() { return ClientMapping.class; } }
4,572
42.971154
155
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/network/NetworkMarshallingProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.network; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; /** * Provides marshallers for the <code>org.jboss.as.network</code> package. * @author Paul Ferraro */ public enum NetworkMarshallingProvider implements ProtoStreamMarshallerProvider { CLIENT_MAPPING(new ClientMappingMarshaller()), ; private final ProtoStreamMarshaller<?> marshaller; NetworkMarshallingProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
1,769
36.659574
84
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/network/NetworkEJBSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.network; import org.infinispan.protostream.SerializationContext; import org.wildfly.clustering.marshalling.protostream.AbstractSerializationContextInitializer; /** * {@link SerializationContextInitializer} for this package. * @author Paul Ferraro */ public class NetworkEJBSerializationContextInitializer extends AbstractSerializationContextInitializer { @Override public void registerMarshallers(SerializationContext context) { context.registerMarshaller(new ClientMappingsRegistryEntryMarshaller()); } }
1,602
40.102564
104
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/network/ClientMappingsRegistryEntryMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.network; import java.io.IOException; import java.util.LinkedList; import java.util.List; import org.infinispan.protostream.descriptors.WireType; import org.jboss.as.network.ClientMapping; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; /** * {@link ProtoStreamMarshaller} for a {@link ClientMappingsRegistryEntry}. * @author Paul Ferraro */ public class ClientMappingsRegistryEntryMarshaller implements ProtoStreamMarshaller<ClientMappingsRegistryEntry> { private static final int MEMBER_INDEX = 1; private static final int CLIENT_MAPPING_INDEX = 2; @Override public ClientMappingsRegistryEntry readFrom(ProtoStreamReader reader) throws IOException { String memberName = null; List<ClientMapping> mappings = new LinkedList<>(); while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case MEMBER_INDEX: memberName = reader.readString(); break; case CLIENT_MAPPING_INDEX: mappings.add(reader.readObject(ClientMapping.class)); break; default: reader.skipField(tag); } } return new ClientMappingsRegistryEntry(memberName, mappings); } @Override public void writeTo(ProtoStreamWriter writer, ClientMappingsRegistryEntry entry) throws IOException { writer.writeString(MEMBER_INDEX, entry.getKey()); for (ClientMapping mapping : entry.getValue()) { writer.writeObject(CLIENT_MAPPING_INDEX, mapping); } } @Override public Class<? extends ClientMappingsRegistryEntry> getJavaClass() { return ClientMappingsRegistryEntry.class; } }
3,033
38.402597
114
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/network/ClientMappingsRegistryEntryServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.network; import java.util.List; import java.util.Map; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.ServiceNameFactory; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.as.network.ClientMapping; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.group.Group; import org.wildfly.clustering.server.service.ClusteringCacheRequirement; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; /** * Configures a service that provides a client mappings registry entry for the local cluster member. * @author Paul Ferraro */ public class ClientMappingsRegistryEntryServiceConfigurator extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, Supplier<Map.Entry<String, List<ClientMapping>>> { private final String containerName; private final String cacheName; private final SupplierDependency<List<ClientMapping>> clientMappings; private volatile SupplierDependency<Group> group; public ClientMappingsRegistryEntryServiceConfigurator(String containerName, String cacheName, SupplierDependency<List<ClientMapping>> clientMappings) { super(ServiceNameFactory.parseServiceName(ClusteringCacheRequirement.REGISTRY_ENTRY.getName()).append(containerName, cacheName)); this.containerName = containerName; this.cacheName = cacheName; this.clientMappings = clientMappings; } @Override public ServiceConfigurator configure(CapabilityServiceSupport support) { this.group = new ServiceSupplierDependency<>(ClusteringCacheRequirement.GROUP.getServiceName(support, this.containerName, this.cacheName)); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<Map.Entry<String, List<ClientMapping>>> entry = new CompositeDependency(this.group, this.clientMappings).register(builder).provides(name); Service service = new FunctionalService<>(entry, Function.identity(), this); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } @Override public Map.Entry<String, List<ClientMapping>> get() { return new ClientMappingsRegistryEntry(this.group.get().getLocalMember().getName(), this.clientMappings.get()); } }
4,104
46.183908
186
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/network/ClientMappingsRegistryEntry.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.network; import java.util.AbstractMap.SimpleImmutableEntry; import java.util.List; import org.jboss.as.network.ClientMapping; /** * Registry entry for the client mappings registry. * @author Paul Ferraro */ public class ClientMappingsRegistryEntry extends SimpleImmutableEntry<String, List<ClientMapping>> { private static final long serialVersionUID = 2252091408161700077L; public ClientMappingsRegistryEntry(String memberName, List<ClientMapping> mappings) { super(memberName, mappings); } }
1,590
38.775
100
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerCreationMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.lang.reflect.Method; import java.time.Instant; import java.util.function.Predicate; import java.util.function.UnaryOperator; import org.wildfly.clustering.ejb.timer.TimerConfiguration; import org.wildfly.clustering.ejb.timer.TimerType; /** * @author Paul Ferraro */ public interface TimerCreationMetaData<V> extends TimerConfiguration, UnaryOperator<Instant> { TimerType getType(); V getContext(); default Predicate<Method> getTimeoutMatcher() { return null; } }
1,583
34.2
94
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerMetaDataFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.util.Map; import org.wildfly.clustering.ee.Creator; import org.wildfly.clustering.ee.Remover; import org.wildfly.clustering.ejb.timer.TimerMetaData; /** * @author Paul Ferraro */ public interface TimerMetaDataFactory<I, V> extends ImmutableTimerMetaDataFactory<I, V>, Creator<I, Map.Entry<TimerCreationMetaData<V>, TimerAccessMetaData>, Map.Entry<TimerCreationMetaData<V>, TimerIndex>>, Remover<I> { TimerMetaData createTimerMetaData(I id, Map.Entry<TimerCreationMetaData<V>, TimerAccessMetaData> entry); }
1,606
41.289474
220
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/IntervalTimerCreationMetaDataMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.io.IOException; import java.time.Duration; import java.time.Instant; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledValue; import org.wildfly.clustering.marshalling.spi.MarshalledValue; /** * @author Paul Ferraro */ public class IntervalTimerCreationMetaDataMarshaller implements ProtoStreamMarshaller<IntervalTimerCreationMetaData<Object>> { private static final int INFO_INDEX = 1; private static final int START_INDEX = 2; private static final int INTERVAL_INDEX = 3; private static final Instant DEFAULT_START = Instant.EPOCH; @SuppressWarnings("unchecked") @Override public Class<? extends IntervalTimerCreationMetaData<Object>> getJavaClass() { return (Class<IntervalTimerCreationMetaDataEntry<Object>>) (Class<?>) IntervalTimerCreationMetaDataEntry.class; } @Override public IntervalTimerCreationMetaData<Object> readFrom(ProtoStreamReader reader) throws IOException { MarshalledValue<Object, Object> context = null; Instant start = DEFAULT_START; Duration interval = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case INFO_INDEX: context = reader.readObject(ByteBufferMarshalledValue.class); break; case START_INDEX: start = reader.readObject(Instant.class); break; case INTERVAL_INDEX: interval = reader.readObject(Duration.class); break; default: reader.skipField(tag); } } return new IntervalTimerCreationMetaDataEntry<>(context, start, interval); } @Override public void writeTo(ProtoStreamWriter writer, IntervalTimerCreationMetaData<Object> metaData) throws IOException { Object context = metaData.getContext(); if (context != null) { writer.writeObject(INFO_INDEX, context); } Instant start = metaData.getStart(); if (!start.equals(DEFAULT_START)) { writer.writeObject(START_INDEX, start); } Duration interval = metaData.getInterval(); if (interval != null) { writer.writeObject(INTERVAL_INDEX, interval); } } }
3,743
39.258065
126
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/InfinispanTimerManagementConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import org.wildfly.clustering.ee.infinispan.InfinispanCacheConfiguration; import org.wildfly.clustering.ejb.timer.TimerManagementConfiguration; /** * @author Paul Ferraro */ public interface InfinispanTimerManagementConfiguration extends TimerManagementConfiguration, InfinispanCacheConfiguration { }
1,383
39.705882
124
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimeoutDescriptor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.lang.reflect.Method; import java.util.function.Predicate; /** * Describes a timeout method. * @author Paul Ferraro */ public class TimeoutDescriptor implements Predicate<Method> { private final String methodName; private final int parameters; public TimeoutDescriptor(Method method) { this(method.getName(), method.getParameterCount()); } public TimeoutDescriptor(String methodName, int parameters) { this.methodName = methodName; this.parameters = parameters; } String getMethodName() { return this.methodName; } int getParameters() { return this.parameters; } @Override public boolean test(Method method) { return method.getName().equals(this.methodName) && method.getParameterCount() == this.parameters; } @Override public boolean equals(Object object) { if (!(object instanceof TimeoutDescriptor)) return false; TimeoutDescriptor descriptor = (TimeoutDescriptor) object; return this.methodName.equals(descriptor.methodName) && this.parameters == descriptor.parameters; } @Override public int hashCode() { return this.methodName.hashCode() + this.parameters; } }
2,324
31.746479
105
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerKeySerializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.UUID; import java.util.function.Function; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.ee.Key; import org.wildfly.clustering.marshalling.spi.BinaryFormatter; import org.wildfly.clustering.marshalling.spi.Formatter; import org.wildfly.clustering.marshalling.spi.Serializer; import org.wildfly.clustering.marshalling.spi.util.UUIDSerializer; /** * Serializer for timer keys. * @author Paul Ferraro */ public class TimerKeySerializer<K extends Key<UUID>> implements Serializer<K> { private final Function<UUID, K> factory; TimerKeySerializer(Function<UUID, K> factory) { this.factory = factory; } @Override public void write(DataOutput output, K value) throws IOException { UUIDSerializer.INSTANCE.write(output, value.getId()); } @Override public K read(DataInput input) throws IOException { return this.factory.apply(UUIDSerializer.INSTANCE.read(input)); } @MetaInfServices(Formatter.class) public static class TimerCreationMetaDataKeyFormatter extends BinaryFormatter<TimerCreationMetaDataKey<UUID>> { @SuppressWarnings("unchecked") public TimerCreationMetaDataKeyFormatter() { super((Class<TimerCreationMetaDataKey<UUID>>) (Class<?>) TimerCreationMetaDataKey.class, new TimerKeySerializer<>(TimerCreationMetaDataKey::new)); } } @MetaInfServices(Formatter.class) public static class TimerAccessMetaDataKeyFormatter extends BinaryFormatter<TimerAccessMetaDataKey<UUID>> { @SuppressWarnings("unchecked") public TimerAccessMetaDataKeyFormatter() { super((Class<TimerAccessMetaDataKey<UUID>>) (Class<?>) TimerAccessMetaDataKey.class, new TimerKeySerializer<>(TimerAccessMetaDataKey::new)); } } }
2,955
37.894737
158
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerCreationMetaDataKey.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import org.wildfly.clustering.ee.infinispan.GroupedKey; /** * @author Paul Ferraro */ public class TimerCreationMetaDataKey<I> extends GroupedKey<I> { public TimerCreationMetaDataKey(I id) { super(id); } }
1,304
35.25
70
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/InfinispanTimerManagerConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.util.function.Supplier; import org.infinispan.remoting.transport.Address; import org.wildfly.clustering.ee.infinispan.InfinispanConfiguration; import org.wildfly.clustering.ejb.timer.TimerRegistry; import org.wildfly.clustering.infinispan.affinity.KeyAffinityServiceFactory; import org.wildfly.clustering.marshalling.spi.Marshaller; import org.wildfly.clustering.server.dispatcher.CommandDispatcherFactory; import org.wildfly.clustering.server.group.Group; /** * @author Paul Ferraro */ public interface InfinispanTimerManagerConfiguration<I, V> extends InfinispanConfiguration { TimerFactory<I, V> getTimerFactory(); TimerRegistry<I> getRegistry(); Marshaller<Object, V> getMarshaller(); Supplier<I> getIdentifierFactory(); KeyAffinityServiceFactory getKeyAffinityServiceFactory(); CommandDispatcherFactory getCommandDispatcherFactory(); Group<Address> getGroup(); }
1,991
40.5
92
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerIndexKeyFormatter.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.spi.DelimitedFormatter; import org.wildfly.clustering.marshalling.spi.Formatter; /** * Formatter for a {@link TimerIndexKey}. * @author Paul Ferraro */ @MetaInfServices(Formatter.class) public class TimerIndexKeyFormatter extends DelimitedFormatter<TimerIndexKey> { public TimerIndexKeyFormatter() { super(TimerIndexKey.class, "#", TimerIndexKeyFormatter::fromStrings, TimerIndexKeyFormatter::toStrings); } static TimerIndexKey fromStrings(String[] values) { String className = values[0]; String methodName = values[1]; int parameters = (values.length == 3) ? 0 : 1; int index = Integer.parseInt(values[values.length - 1]); return new TimerIndexKey(new TimerIndex(className, methodName, parameters, index)); } static String[] toStrings(TimerIndexKey key) { TimerIndex index = key.getId(); int parameters = index.getParameters(); String indexValue = Integer.toString(index.getIndex()); return (parameters == 0) ? new String[] { index.getDeclaringClassName(), index.getMethodName(), indexValue } : new String[] { index.getDeclaringClassName(), index.getMethodName(), "", indexValue }; } }
2,354
41.818182
205
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerAccessMetaDataEntry.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.time.Duration; import java.util.Map; /** * @author Paul Ferraro */ public class TimerAccessMetaDataEntry<I> implements TimerAccessMetaData { private final Map<TimerAccessMetaDataKey<I>, Duration> cache; private final TimerAccessMetaDataKey<I> key; public TimerAccessMetaDataEntry(Map<TimerAccessMetaDataKey<I>, Duration> cache, TimerAccessMetaDataKey<I> key) { this.cache = cache; this.key = key; } @Override public Duration getLastTimout() { return this.cache.get(this.key); } @Override public void setLastTimeout(Duration lastTimeout) { if (lastTimeout != null) { this.cache.put(this.key, lastTimeout); } else { this.cache.remove(this.key); } } }
1,858
32.8
116
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerAccessMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.time.Duration; /** * @author Paul Ferraro */ public interface TimerAccessMetaData { Duration getLastTimout(); void setLastTimeout(Duration sinceCreation); }
1,259
35
70
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/ScheduleTimerCreationMetaDataMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.io.IOException; import java.time.Instant; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledValue; import org.wildfly.clustering.marshalling.spi.MarshalledValue; /** * @author Paul Ferraro */ public class ScheduleTimerCreationMetaDataMarshaller implements ProtoStreamMarshaller<ScheduleTimerCreationMetaData<Object>> { private static final int INFO_INDEX = 1; private static final int START_INDEX = 2; private static final int SCHEDULE_EXPRESSION_INDEX = 3; private static final int NO_PARAMETERS_METHOD_NAME_INDEX = SCHEDULE_EXPRESSION_INDEX + ImmutableScheduleExpressionMarshaller.INSTANCE.getFields(); private static final int TIMER_PARAMETERS_METHOD_NAME_INDEX = NO_PARAMETERS_METHOD_NAME_INDEX + 1; @SuppressWarnings("unchecked") @Override public Class<? extends ScheduleTimerCreationMetaData<Object>> getJavaClass() { return (Class<ScheduleTimerCreationMetaDataEntry<Object>>) (Class<?>) ScheduleTimerCreationMetaDataEntry.class; } @Override public ScheduleTimerCreationMetaData<Object> readFrom(ProtoStreamReader reader) throws IOException { Instant creation = Instant.EPOCH; MarshalledValue<Object, Object> context = null; ImmutableScheduleExpressionBuilder expressionBuilder = ImmutableScheduleExpressionMarshaller.INSTANCE.getBuilder(); TimeoutDescriptor descriptor = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); int index = WireType.getTagFieldNumber(tag); if (index == START_INDEX) { creation = reader.readObject(Instant.class); } else if (index == INFO_INDEX) { context = reader.readObject(ByteBufferMarshalledValue.class); } else if ((index >= SCHEDULE_EXPRESSION_INDEX) && (index < NO_PARAMETERS_METHOD_NAME_INDEX)) { expressionBuilder = ImmutableScheduleExpressionMarshaller.INSTANCE.readField(reader, index - SCHEDULE_EXPRESSION_INDEX, expressionBuilder); } else if (index == NO_PARAMETERS_METHOD_NAME_INDEX) { descriptor = new TimeoutDescriptor(reader.readString(), 0); } else if (index == TIMER_PARAMETERS_METHOD_NAME_INDEX) { descriptor = new TimeoutDescriptor(reader.readString(), 1); } else { reader.skipField(tag); } } return new ScheduleTimerCreationMetaDataEntry<>(context, creation, expressionBuilder.build(), descriptor); } @Override public void writeTo(ProtoStreamWriter writer, ScheduleTimerCreationMetaData<Object> metaData) throws IOException { Object context = metaData.getContext(); if (context != null) { writer.writeObject(INFO_INDEX, context); } Instant start = metaData.getStart(); if (!start.equals(Instant.EPOCH)) { writer.writeObject(START_INDEX, start); } ImmutableScheduleExpressionMarshaller.INSTANCE.writeFields(writer, SCHEDULE_EXPRESSION_INDEX, metaData.getScheduleExpression()); TimeoutDescriptor descriptor = metaData.getTimeoutMatcher(); if (descriptor != null) { writer.writeString(descriptor.getParameters() > 0 ? TIMER_PARAMETERS_METHOD_NAME_INDEX : NO_PARAMETERS_METHOD_NAME_INDEX, descriptor.getMethodName()); } } }
4,724
48.736842
162
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/CompositeTimerMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.time.Duration; import java.time.Instant; import org.wildfly.clustering.ejb.timer.TimerMetaData; /** * @author Paul Ferraro */ public class CompositeTimerMetaData<V> extends CompositeImmutableTimerMetaData<V> implements TimerMetaData { private final TimerCreationMetaData<V> creationMetaData; private final TimerAccessMetaData accessMetaData; public CompositeTimerMetaData(TimerMetaDataConfiguration<V> configuration, TimerCreationMetaData<V> creationMetaData, TimerAccessMetaData accessMetaData) { super(configuration, creationMetaData, accessMetaData); this.creationMetaData = creationMetaData; this.accessMetaData = accessMetaData; } @Override public void setLastTimout(Instant timeout) { this.accessMetaData.setLastTimeout((timeout != null) ? Duration.between(this.creationMetaData.getStart(), timeout) : null); } }
1,976
39.346939
159
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/InfinispanTimerManagerFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.util.function.Supplier; import org.infinispan.Cache; import org.infinispan.remoting.transport.Address; import org.wildfly.clustering.ee.Batcher; import org.wildfly.clustering.ee.cache.CacheProperties; import org.wildfly.clustering.ee.cache.tx.TransactionBatch; import org.wildfly.clustering.ejb.timer.TimerManager; import org.wildfly.clustering.ejb.timer.TimerManagerConfiguration; import org.wildfly.clustering.ejb.timer.TimerManagerFactory; import org.wildfly.clustering.ejb.timer.TimerRegistry; import org.wildfly.clustering.infinispan.affinity.KeyAffinityServiceFactory; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledValueFactory; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.marshalling.spi.MarshalledValue; import org.wildfly.clustering.marshalling.spi.MarshalledValueMarshaller; import org.wildfly.clustering.marshalling.spi.Marshaller; import org.wildfly.clustering.server.dispatcher.CommandDispatcherFactory; import org.wildfly.clustering.server.group.Group; /** * @author Paul Ferraro */ public class InfinispanTimerManagerFactory<I> implements TimerManagerFactory<I, TransactionBatch> { private final InfinispanTimerManagerFactoryConfiguration<I> configuration; public InfinispanTimerManagerFactory(InfinispanTimerManagerFactoryConfiguration<I> configuration) { this.configuration = configuration; } @Override public TimerManager<I, TransactionBatch> createTimerManager(TimerManagerConfiguration<I, TransactionBatch> configuration) { InfinispanTimerManagerFactoryConfiguration<I> factoryConfiguration = this.configuration; Marshaller<Object, MarshalledValue<Object, ByteBufferMarshaller>> marshaller = new MarshalledValueMarshaller<>(new ByteBufferMarshalledValueFactory(this.configuration.getMarshaller())); TimerMetaDataConfiguration<MarshalledValue<Object, ByteBufferMarshaller>> metaDataFactoryConfig = new TimerMetaDataConfiguration<>() { @Override public Marshaller<Object, MarshalledValue<Object, ByteBufferMarshaller>> getMarshaller() { return marshaller; } @Override public boolean isPersistent() { return configuration.isPersistent(); } @Override public <K, V> Cache<K, V> getCache() { return factoryConfiguration.getCache(); } }; TimerMetaDataFactory<I, MarshalledValue<Object, ByteBufferMarshaller>> metaDataFactory = new InfinispanTimerMetaDataFactory<>(metaDataFactoryConfig); TimerFactory<I, MarshalledValue<Object, ByteBufferMarshaller>> factory = new InfinispanTimerFactory<>(metaDataFactory, configuration.getListener(), this.configuration.getRegistry()); return new InfinispanTimerManager<>(new InfinispanTimerManagerConfiguration<I, MarshalledValue<Object, ByteBufferMarshaller>>() { @Override public <K, V> Cache<K, V> getCache() { return factoryConfiguration.getCache(); } @Override public CacheProperties getCacheProperties() { return factoryConfiguration.getCacheProperties(); } @Override public TimerFactory<I, MarshalledValue<Object, ByteBufferMarshaller>> getTimerFactory() { return factory; } @Override public TimerRegistry<I> getRegistry() { return factoryConfiguration.getRegistry(); } @Override public Marshaller<Object, MarshalledValue<Object, ByteBufferMarshaller>> getMarshaller() { return marshaller; } @Override public Batcher<TransactionBatch> getBatcher() { return factoryConfiguration.getBatcher(); } @Override public Supplier<I> getIdentifierFactory() { return factoryConfiguration.getIdentifierFactory(); } @Override public KeyAffinityServiceFactory getKeyAffinityServiceFactory() { return factoryConfiguration.getKeyAffinityServiceFactory(); } @Override public CommandDispatcherFactory getCommandDispatcherFactory() { return factoryConfiguration.getCommandDispatcherFactory(); } @Override public Group<Address> getGroup() { return factoryConfiguration.getGroup(); } }); } }
5,682
41.729323
193
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerMetaDataConfiguration.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import org.wildfly.clustering.ee.infinispan.InfinispanConfiguration; import org.wildfly.clustering.marshalling.spi.Marshaller; /** * @author Paul Ferraro */ public interface TimerMetaDataConfiguration<V> extends InfinispanConfiguration { Marshaller<Object, V> getMarshaller(); boolean isPersistent(); }
1,393
37.722222
80
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerScheduler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.time.Duration; import java.time.Instant; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; import org.wildfly.clustering.context.DefaultThreadFactory; import org.wildfly.clustering.ee.Scheduler; import org.wildfly.clustering.ee.cache.scheduler.LocalScheduler; import org.wildfly.clustering.ee.cache.scheduler.ScheduledEntries; import org.wildfly.clustering.ee.cache.scheduler.SortedScheduledEntries; import org.wildfly.clustering.ee.cache.tx.TransactionBatch; import org.wildfly.clustering.ee.infinispan.GroupedKey; import org.wildfly.clustering.ee.infinispan.scheduler.AbstractCacheEntryScheduler; import org.wildfly.clustering.ejb.infinispan.logging.InfinispanEjbLogger; import org.wildfly.clustering.ejb.timer.ImmutableTimerMetaData; import org.wildfly.clustering.ejb.timer.Timer; import org.wildfly.clustering.ejb.timer.TimerManager; import org.wildfly.clustering.ejb.timer.TimerMetaData; import org.wildfly.clustering.ejb.timer.TimerRegistry; import org.wildfly.clustering.infinispan.distribution.Locality; /** * @author Paul Ferraro */ public class TimerScheduler<I, C> extends AbstractCacheEntryScheduler<I, ImmutableTimerMetaData> { private final TimerFactory<I, C> factory; public TimerScheduler(TimerFactory<I, C> factory, TimerManager<I, TransactionBatch> manager, Supplier<Locality> locality, Duration closeTimeout, TimerRegistry<I> registry) { this(factory, manager, locality, closeTimeout, registry, new SortedScheduledEntries<>(), Executors.newSingleThreadExecutor(new DefaultThreadFactory(TimerScheduler.class))); } private TimerScheduler(TimerFactory<I, C> factory, TimerManager<I, TransactionBatch> manager, Supplier<Locality> locality, Duration closeTimeout, TimerRegistry<I> registry, ScheduledEntries<I, Instant> entries, ExecutorService executor) { this(entries, new InvokeTask<>(factory, manager, locality, entries, registry, executor), closeTimeout, registry, executor, factory); } private <T extends Predicate<I> & Consumer<Scheduler<I, ImmutableTimerMetaData>>> TimerScheduler(ScheduledEntries<I, Instant> entries, T invokeTask, Duration closeTimeout, TimerRegistry<I> registry, ExecutorService executor, TimerFactory<I, C> factory) { this(new LocalScheduler<>(entries, invokeTask, closeTimeout) { @Override public void cancel(I id) { registry.unregister(id); super.cancel(id); } @Override public void close() { super.close(); executor.shutdown(); } }, invokeTask, factory); } private TimerScheduler(Scheduler<I, Instant> scheduler, Consumer<Scheduler<I, ImmutableTimerMetaData>> injector, TimerFactory<I, C> factory) { super(scheduler, ImmutableTimerMetaData::getNextTimeout); this.factory = factory; injector.accept(this); } @Override public void schedule(I id) { TimerMetaDataFactory<I, C> metaDataFactory = this.factory.getMetaDataFactory(); Map.Entry<TimerCreationMetaData<C>, TimerAccessMetaData> entry = metaDataFactory.findValue(id); if (entry != null) { ImmutableTimerMetaData metaData = metaDataFactory.createImmutableTimerMetaData(entry); this.schedule(id, metaData); } } private static class InvokeTask<I, C> implements Predicate<I>, Consumer<Scheduler<I, ImmutableTimerMetaData>> { private final TimerFactory<I, C> factory; private final TimerManager<I, TransactionBatch> manager; private final Supplier<Locality> locality; private final ScheduledEntries<I, Instant> entries; private final TimerRegistry<I> registry; private final ExecutorService executor; private Scheduler<I, ImmutableTimerMetaData> scheduler; InvokeTask(TimerFactory<I, C> factory, TimerManager<I, TransactionBatch> manager, Supplier<Locality> locality, ScheduledEntries<I, Instant> entries, TimerRegistry<I> registry, ExecutorService executor) { this.factory = factory; this.manager = manager; this.locality = locality; this.entries = entries; this.registry = registry; this.executor = executor; } @Override public void accept(Scheduler<I, ImmutableTimerMetaData> scheduler) { this.scheduler = scheduler; } @Override public boolean test(I id) { TimerFactory<I, C> factory = this.factory; TimerManager<I, TransactionBatch> manager = this.manager; Supplier<Locality> locality = this.locality; ScheduledEntries<I, Instant> entries = this.entries; TimerRegistry<I> registry = this.registry; Scheduler<I, ImmutableTimerMetaData> scheduler = this.scheduler; // Ensure timer is owned by local member if (!locality.get().isLocal(new GroupedKey<>(id))) { InfinispanEjbLogger.ROOT_LOGGER.debugf("Skipping timeout processing of non-local timer %s", id); return true; } Callable<Boolean> task = new Callable<>() { @Override public Boolean call() throws Exception { InfinispanEjbLogger.ROOT_LOGGER.debugf("Initiating timeout for timer %s", id); TimerMetaDataFactory<I, C> metaDataFactory = factory.getMetaDataFactory(); try (TransactionBatch batch = manager.getBatcher().createBatch()) { Map.Entry<TimerCreationMetaData<C>, TimerAccessMetaData> entry = metaDataFactory.findValue(id); if (entry == null) { InfinispanEjbLogger.ROOT_LOGGER.debugf("Timer not found %s", id); return true; } TimerMetaData metaData = metaDataFactory.createTimerMetaData(id, entry); Instant currentTimeout = metaData.getNextTimeout(); // Safeguard : ensure timeout was not already triggered elsewhere if (currentTimeout.isAfter(Instant.now())) { InfinispanEjbLogger.ROOT_LOGGER.debugf("Timeout for timer %s initiated prematurely.", id); return false; } Timer<I> timer = factory.createTimer(id, metaData, manager, scheduler); InfinispanEjbLogger.ROOT_LOGGER.debugf("Triggering timeout for timer %s [%s]", id, timer.getMetaData().getContext()); // In case we need to reset the last timeout Instant lastTimeout = metaData.getLastTimout(); // Record last timeout - expected to be set prior to triggering timeout metaData.setLastTimout(currentTimeout); try { timer.invoke(); } catch (ExecutionException e) { // Log error and proceed as if it was successful InfinispanEjbLogger.ROOT_LOGGER.error(e.getLocalizedMessage(), e); } catch (RejectedExecutionException e) { // Component is not started or is suspended InfinispanEjbLogger.ROOT_LOGGER.debugf("EJB component is suspended - could not invoke timeout for timer %s", id); // Reset last timeout metaData.setLastTimout(lastTimeout); return false; } // If timeout callback canceled this timer if (timer.isCanceled()) { InfinispanEjbLogger.ROOT_LOGGER.debugf("Timeout callback canceled timer %s", id); return true; } // Determine next timeout Instant nextTimeout = metaData.getNextTimeout(); if (nextTimeout == null) { InfinispanEjbLogger.ROOT_LOGGER.debugf("Timer %s has expired", id); registry.unregister(id); factory.getMetaDataFactory().remove(id); return true; } // Only reschedule if timer is still local if (!locality.get().isLocal(new GroupedKey<>(id))) { InfinispanEjbLogger.ROOT_LOGGER.debugf("Timer %s is no longer local", id); return true; } // Reschedule using next timeout InfinispanEjbLogger.ROOT_LOGGER.debugf("Rescheduling timer %s for next timeout %s", id, nextTimeout); entries.add(id, nextTimeout); return false; } } }; try { Future<Boolean> result = this.executor.submit(task); return result.get(); } catch (RejectedExecutionException e) { // Scheduler was shutdown return false; } catch (InterruptedException e) { Thread.currentThread().interrupt(); // Timer was canceled by the scheduler return false; } catch (ExecutionException e) { InfinispanEjbLogger.ROOT_LOGGER.info(e.getLocalizedMessage(), e); return false; } } } }
11,151
48.564444
258
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/ScheduleTimerOperatorFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.time.Instant; import java.util.ServiceLoader; import java.util.function.UnaryOperator; import org.wildfly.clustering.ejb.timer.ImmutableScheduleExpression; import org.wildfly.clustering.ejb.timer.ScheduleTimerOperationProvider; /** * @author Paul Ferraro */ public enum ScheduleTimerOperatorFactory implements ScheduleTimerOperationProvider { INSTANCE; private final ScheduleTimerOperationProvider provider; ScheduleTimerOperatorFactory() { this.provider = load(); } private static ScheduleTimerOperationProvider load() { for (ScheduleTimerOperationProvider provider : ServiceLoader.load(ScheduleTimerOperationProvider.class, ScheduleTimerOperationProvider.class.getClassLoader())) { return provider; } throw new IllegalStateException(); } @Override public UnaryOperator<Instant> createOperator(ImmutableScheduleExpression expression) { return this.provider.createOperator(expression); } }
2,076
36.089286
169
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/ScheduleTimerCreationMetaDataEntry.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.lang.reflect.Method; import java.time.Instant; import java.util.function.UnaryOperator; import org.wildfly.clustering.ejb.timer.ImmutableScheduleExpression; import org.wildfly.clustering.ejb.timer.ScheduleTimerConfiguration; /** * Cache value for scheduled-based timer creation meta data. * @author Paul Ferraro */ public class ScheduleTimerCreationMetaDataEntry<V> extends AbstractTimerCreationMetaDataEntry<V> implements ScheduleTimerCreationMetaData<V> { private final ImmutableScheduleExpression expression; private final TimeoutDescriptor descriptor; private volatile UnaryOperator<Instant> operator = null; public ScheduleTimerCreationMetaDataEntry(V context, ScheduleTimerConfiguration config, Method method) { // Create operator eagerly when timer entry is created this(context, config, method != null ? new TimeoutDescriptor(method) : null, ScheduleTimerOperatorFactory.INSTANCE.createOperator(config.getScheduleExpression())); } private ScheduleTimerCreationMetaDataEntry(V context, ScheduleTimerConfiguration config, TimeoutDescriptor descriptor, UnaryOperator<Instant> operator) { // Use operator to calculate start time this(context, operator.apply(null), config.getScheduleExpression(), descriptor, operator); } public ScheduleTimerCreationMetaDataEntry(V context, Instant start, ImmutableScheduleExpression expression, TimeoutDescriptor descriptor) { // Create operator lazily this(context, start, expression, descriptor, null); } private ScheduleTimerCreationMetaDataEntry(V context, Instant start, ImmutableScheduleExpression expression, TimeoutDescriptor descriptor, UnaryOperator<Instant> operator) { super(context, start); this.expression = expression; this.descriptor = descriptor; this.operator = operator; } /* Get operator, lazily creating if necessary */ private UnaryOperator<Instant> getOperator() { if (this.operator == null) { synchronized (this) { if (this.operator == null) { this.operator = ScheduleTimerOperatorFactory.INSTANCE.createOperator(this.expression); } } } return this.operator; } @Override public ImmutableScheduleExpression getScheduleExpression() { return this.expression; } @Override public TimeoutDescriptor getTimeoutMatcher() { return this.descriptor; } @Override public Instant apply(Instant lastTimeout) { return (lastTimeout != null) ? this.getOperator().apply(lastTimeout) : this.getStart(); } }
3,751
39.782609
177
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/InfinispanTimerFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import org.wildfly.clustering.ee.Scheduler; import org.wildfly.clustering.ee.cache.tx.TransactionBatch; import org.wildfly.clustering.ejb.timer.Timer; import org.wildfly.clustering.ejb.timer.TimerManager; import org.wildfly.clustering.ejb.timer.ImmutableTimerMetaData; import org.wildfly.clustering.ejb.timer.TimeoutListener; import org.wildfly.clustering.ejb.timer.TimerRegistry; /** * @author Paul Ferraro */ public class InfinispanTimerFactory<I, V> implements TimerFactory<I, V> { private final TimerMetaDataFactory<I, V> factory; private final TimeoutListener<I, TransactionBatch> listener; private final TimerRegistry<I> registry; public InfinispanTimerFactory(TimerMetaDataFactory<I, V> factory, TimeoutListener<I, TransactionBatch> listener, TimerRegistry<I> registry) { this.factory = factory; this.listener = listener; this.registry = registry; } @Override public Timer<I> createTimer(I id, ImmutableTimerMetaData metaData, TimerManager<I, TransactionBatch> manager, Scheduler<I, ImmutableTimerMetaData> scheduler) { return new InfinispanTimer<>(manager, id, metaData, scheduler, this.listener, this.factory, this.registry); } @Override public TimerMetaDataFactory<I, V> getMetaDataFactory() { return this.factory; } }
2,398
40.362069
163
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/ImmutableScheduleExpressionBuilder.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.time.Instant; import java.time.ZoneId; import org.wildfly.clustering.ejb.timer.ImmutableScheduleExpression; /** * @author Paul Ferraro */ public class ImmutableScheduleExpressionBuilder { private String second = "0"; private String minute = "0"; private String hour = "0"; private String dayOfMonth = "*"; private String month = "*"; private String dayOfWeek = "*"; private String year = "*"; private ZoneId zone; private Instant start; private Instant end; public ImmutableScheduleExpressionBuilder second(String second) { this.second = second; return this; } public ImmutableScheduleExpressionBuilder minute(String minute) { this.minute = minute; return this; } public ImmutableScheduleExpressionBuilder hour(String hour) { this.hour = hour; return this; } public ImmutableScheduleExpressionBuilder dayOfMonth(String dayOfMonth) { this.dayOfMonth = dayOfMonth; return this; } public ImmutableScheduleExpressionBuilder month(String month) { this.month = month; return this; } public ImmutableScheduleExpressionBuilder dayOfWeek(String dayOfWeek) { this.dayOfWeek = dayOfWeek; return this; } public ImmutableScheduleExpressionBuilder year(String year) { this.year = year; return this; } public ImmutableScheduleExpressionBuilder zone(ZoneId zone) { this.zone = zone; return this; } public ImmutableScheduleExpressionBuilder start(Instant start) { this.start = start; return this; } public ImmutableScheduleExpressionBuilder end(Instant end) { this.end = end; return this; } public ImmutableScheduleExpression build() { String second = this.second; String minute = this.minute; String hour = this.hour; String dayOfMonth = this.dayOfMonth; String month = this.month; String dayOfWeek = this.dayOfWeek; String year = this.year; ZoneId zone = this.zone; Instant start = this.start; Instant end = this.end; return new ImmutableScheduleExpression() { @Override public String getSecond() { return second; } @Override public String getMinute() { return minute; } @Override public String getHour() { return hour; } @Override public String getDayOfMonth() { return dayOfMonth; } @Override public String getMonth() { return month; } @Override public String getDayOfWeek() { return dayOfWeek; } @Override public String getYear() { return year; } @Override public ZoneId getZone() { return zone; } @Override public Instant getStart() { return start; } @Override public Instant getEnd() { return end; } }; } }
4,419
26.116564
77
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/AbstractTimerCreationMetaDataEntry.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.time.Instant; import java.time.temporal.ChronoUnit; import org.wildfly.clustering.ejb.timer.TimerConfiguration; /** * @author Paul Ferraro */ public abstract class AbstractTimerCreationMetaDataEntry<V> implements TimerCreationMetaData<V> { private final V context; private final Instant start; protected AbstractTimerCreationMetaDataEntry(V context, TimerConfiguration config) { this(context, config.getStart()); } protected AbstractTimerCreationMetaDataEntry(V context, Instant start) { this.context = context; this.start = (start != null) ? start.truncatedTo(ChronoUnit.MILLIS) : null; } @Override public V getContext() { return this.context; } @Override public Instant getStart() { return this.start; } }
1,895
32.263158
97
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/IntervalTimerCreationMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import org.wildfly.clustering.ejb.timer.IntervalTimerConfiguration; import org.wildfly.clustering.ejb.timer.TimerType; /** * @author Paul Ferraro */ public interface IntervalTimerCreationMetaData<V> extends TimerCreationMetaData<V>, IntervalTimerConfiguration { @Override default TimerType getType() { return TimerType.INTERVAL; } }
1,434
37.783784
112
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerIndexKey.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import org.wildfly.clustering.ee.infinispan.GroupedKey; /** * @author Paul Ferraro */ public class TimerIndexKey extends GroupedKey<TimerIndex> { public TimerIndexKey(TimerIndex index) { super(index); } }
1,303
35.222222
70
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/InfinispanTimerManagerFactoryServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import java.util.List; import java.util.ServiceLoader; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.infinispan.Cache; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.ExpirationConfiguration; import org.infinispan.configuration.cache.StorageType; import org.infinispan.eviction.EvictionStrategy; import org.infinispan.remoting.transport.Address; import org.infinispan.transaction.LockingMode; import org.infinispan.transaction.TransactionMode; import org.infinispan.transaction.tm.EmbeddedTransactionManager; import org.infinispan.util.concurrent.IsolationLevel; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.clustering.controller.CompositeServiceBuilder; import org.jboss.as.clustering.controller.CompositeServiceConfigurator; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.ee.cache.tx.TransactionBatch; import org.wildfly.clustering.ejb.timer.TimerManagerFactory; import org.wildfly.clustering.ejb.timer.TimerManagerFactoryConfiguration; import org.wildfly.clustering.ejb.timer.TimerRegistry; import org.wildfly.clustering.ejb.timer.TimerServiceConfiguration; import org.wildfly.clustering.infinispan.affinity.KeyAffinityServiceFactory; import org.wildfly.clustering.infinispan.container.DataContainerConfigurationBuilder; import org.wildfly.clustering.infinispan.service.CacheServiceConfigurator; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.InfinispanRequirement; import org.wildfly.clustering.infinispan.service.TemplateConfigurationServiceConfigurator; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.server.dispatcher.CommandDispatcherFactory; import org.wildfly.clustering.server.group.Group; import org.wildfly.clustering.server.service.CacheServiceConfiguratorProvider; import org.wildfly.clustering.server.service.ClusteringCacheRequirement; import org.wildfly.clustering.server.service.ClusteringRequirement; import org.wildfly.clustering.server.service.DistributedCacheServiceConfiguratorProvider; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; /** * @author Paul Ferraro */ public class InfinispanTimerManagerFactoryServiceConfigurator<I, C> extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, InfinispanTimerManagerFactoryConfiguration<I>, Supplier<TimerManagerFactory<I, TransactionBatch>>, Consumer<ConfigurationBuilder> { private final InfinispanTimerManagementConfiguration configuration; private final TimerManagerFactoryConfiguration<I> factoryConfiguration; private final boolean persistent; private volatile CompositeServiceConfigurator dependenciesConfigurator; private volatile SupplierDependency<KeyAffinityServiceFactory> affinityFactory; private volatile SupplierDependency<CommandDispatcherFactory> dispatcherFactory; private volatile SupplierDependency<Group<Address>> group; @SuppressWarnings("rawtypes") private volatile Supplier<Cache> cache; public InfinispanTimerManagerFactoryServiceConfigurator(InfinispanTimerManagementConfiguration configuration, TimerManagerFactoryConfiguration<I> factoryConfiguration) { super(ServiceName.JBOSS.append("clustering", "timer").append(factoryConfiguration.getTimerServiceConfiguration().getName())); this.configuration = configuration; this.factoryConfiguration = factoryConfiguration; this.persistent = factoryConfiguration.isPersistent(); } @Override public TimerManagerFactory<I, TransactionBatch> get() { return new InfinispanTimerManagerFactory<>(this); } @Override public ServiceConfigurator configure(CapabilityServiceSupport support) { String containerName = this.configuration.getContainerName(); String cacheName = this.configuration.getCacheName(); String beanName = this.factoryConfiguration.getTimerServiceConfiguration().getName(); ServiceName cacheServiceName = InfinispanCacheRequirement.CACHE.getServiceName(support, containerName, beanName); this.dependenciesConfigurator = new CompositeServiceConfigurator(cacheServiceName); this.dependenciesConfigurator.accept(new TemplateConfigurationServiceConfigurator(InfinispanCacheRequirement.CONFIGURATION.getServiceName(support, containerName, beanName), containerName, beanName, cacheName, this).configure(support)); this.dependenciesConfigurator.accept(new CacheServiceConfigurator<>(cacheServiceName, containerName, beanName).configure(support)); for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(DistributedCacheServiceConfiguratorProvider.class, DistributedCacheServiceConfiguratorProvider.class.getClassLoader())) { for (ServiceConfigurator configurator : provider.getServiceConfigurators(support, this.configuration.getContainerName(), beanName)) { this.dependenciesConfigurator.accept(configurator); } } this.affinityFactory = new ServiceSupplierDependency<>(InfinispanRequirement.KEY_AFFINITY_FACTORY.getServiceName(support, containerName)); this.dispatcherFactory = new ServiceSupplierDependency<>(ClusteringRequirement.COMMAND_DISPATCHER_FACTORY.getServiceName(support, containerName)); this.group = new ServiceSupplierDependency<>(ClusteringCacheRequirement.GROUP.getServiceName(support, containerName, beanName)); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<TimerManagerFactory<I, TransactionBatch>> consumer = new CompositeDependency(this.affinityFactory, this.dispatcherFactory, this.group).register(builder).provides(name); this.cache = builder.requires(this.dependenciesConfigurator.getServiceName()); builder.setInstance(new FunctionalService<>(consumer, Function.identity(), this)).setInitialMode(ServiceController.Mode.ON_DEMAND); return new CompositeServiceBuilder<>(List.of(this.dependenciesConfigurator.build(target), builder)); } @Override public void accept(ConfigurationBuilder builder) { // Ensure expiration is not enabled on cache ExpirationConfiguration expiration = builder.expiration().create(); if ((expiration.lifespan() >= 0) || (expiration.maxIdle() >= 0)) { builder.expiration().lifespan(-1).maxIdle(-1); } Integer size = this.configuration.getMaxActiveTimers(); EvictionStrategy strategy = (size != null) ? EvictionStrategy.REMOVE : EvictionStrategy.NONE; builder.memory().storage(StorageType.HEAP).whenFull(strategy).maxCount((size != null) ? size.longValue() : 0); if (strategy.isEnabled()) { // Only evict creation meta-data entries // We will cascade eviction to the remaining entries for a given session builder.addModule(DataContainerConfigurationBuilder.class).evictable(TimerCreationMetaDataKey.class::isInstance); } builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).transactionManagerLookup(() -> EmbeddedTransactionManager.getInstance()).lockingMode(LockingMode.PESSIMISTIC).locking().isolationLevel(IsolationLevel.REPEATABLE_READ); builder.persistence().passivation(false); } @Override public TimerServiceConfiguration getTimerServiceConfiguration() { return this.factoryConfiguration.getTimerServiceConfiguration(); } @Override public Supplier<I> getIdentifierFactory() { return this.factoryConfiguration.getIdentifierFactory(); } @Override public ByteBufferMarshaller getMarshaller() { return this.configuration.getMarshallerFactory().apply(this.factoryConfiguration.getTimerServiceConfiguration().getModule()); } @Override public <K, V> Cache<K, V> getCache() { return this.cache.get(); } @Override public KeyAffinityServiceFactory getKeyAffinityServiceFactory() { return this.affinityFactory.get(); } @Override public CommandDispatcherFactory getCommandDispatcherFactory() { return this.dispatcherFactory.get(); } @Override public Group<Address> getGroup() { return this.group.get(); } @Override public TimerRegistry<I> getRegistry() { return this.factoryConfiguration.getRegistry(); } @Override public boolean isPersistent() { return this.persistent; } }
10,342
50.457711
275
java
null
wildfly-main/clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/timer/TimerFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., 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.wildfly.clustering.ejb.infinispan.timer; import org.wildfly.clustering.ejb.timer.Timer; import org.wildfly.clustering.ejb.timer.TimerManager; import org.wildfly.clustering.ee.Scheduler; import org.wildfly.clustering.ee.cache.tx.TransactionBatch; import org.wildfly.clustering.ejb.timer.ImmutableTimerMetaData; /** * @author Paul Ferraro */ public interface TimerFactory<I, C> { TimerMetaDataFactory<I, C> getMetaDataFactory(); Timer<I> createTimer(I id, ImmutableTimerMetaData metaData, TimerManager<I, TransactionBatch> manager, Scheduler<I, ImmutableTimerMetaData> scheduler); }
1,631
39.8
155
java