Skip to content

Commit

Permalink
Merge branch 'Issue-2274'
Browse files Browse the repository at this point in the history
  • Loading branch information
gvagenas committed Jul 7, 2017
2 parents 54bb452 + 78c16ea commit 69b20b7
Show file tree
Hide file tree
Showing 79 changed files with 2,052 additions and 1,668 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private MediaServerControllerFactory mediaServerControllerFactory(final Configur
try {
settings = configuration.subset("media-server-manager");
ActorRef mrb = mediaResourceBroker(settings, storage, loader);
factory = new MmsControllerFactory(system, mrb);
factory = new MmsControllerFactory(mrb);
} catch (UnknownHostException e) {
throw new ServletException(e);
}
Expand All @@ -98,7 +98,7 @@ private MediaServerControllerFactory mediaServerControllerFactory(final Configur
// Create JSR 309 factory
MsControlFactory msControlFactory = driver.getFactory(properties);
MediaServerInfo mediaServerInfo = mediaServerInfo(settings);
factory = new Jsr309ControllerFactory(system, mediaServerInfo, msControlFactory);
factory = new Jsr309ControllerFactory(mediaServerInfo, msControlFactory);
} catch (UnknownHostException | MsControlException e) {
throw new ServletException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,22 @@
package org.restcomm.connect.asr;

import akka.actor.ActorRef;
import akka.actor.UntypedActor;

import com.iSpeech.SpeechResult;
import com.iSpeech.iSpeechRecognizer;
import static com.iSpeech.iSpeechRecognizer.*;
import com.iSpeech.iSpeechRecognizer.SpeechRecognizerEvent;
import org.apache.commons.configuration.Configuration;
import org.restcomm.connect.commons.faulttolerance.RestcommUntypedActor;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.configuration.Configuration;
import static com.iSpeech.iSpeechRecognizer.FREEFORM_DICTATION;

/**
* @author [email protected] (Thomas Quintana)
*/
public final class ISpeechAsr extends UntypedActor implements SpeechRecognizerEvent {
public final class ISpeechAsr extends RestcommUntypedActor implements SpeechRecognizerEvent {
private static final Map<String, String> languages = new HashMap<String, String>();
static {
languages.put("en", "en-US");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
package org.restcomm.connect.commons.cache;

import akka.actor.ActorRef;
import akka.actor.UntypedActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.restcomm.connect.commons.faulttolerance.RestcommUntypedActor;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -39,7 +39,7 @@
/**
* @author [email protected] (Thomas Quintana)
*/
public final class DiskCache extends UntypedActor {
public final class DiskCache extends RestcommUntypedActor {
// Logger.
private final LoggingAdapter logger = Logging.getLogger(getContext().system(), this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@ public class RestcommSupervisorStrategy implements SupervisorStrategyConfigurato

private static Logger logger = Logger.getLogger(RestcommSupervisorStrategy.class);

final SupervisorStrategy.Directive strategy = resume();
static final SupervisorStrategy.Directive strategy = resume();

RestcommFaultToleranceStrategy defaultStrategy = new RestcommFaultToleranceStrategy(10, Duration.create("1 minute"),
static RestcommFaultToleranceStrategy defaultStrategy = new RestcommFaultToleranceStrategy(10, Duration.create("1 minute"),
new RestcommFaultToleranceDecider());

@Override
public SupervisorStrategy create() {
return defaultStrategy;
}

private class RestcommFaultToleranceStrategy extends OneForOneStrategy {
public static SupervisorStrategy getStrategy() {
return defaultStrategy;
}

private static class RestcommFaultToleranceStrategy extends OneForOneStrategy {

public RestcommFaultToleranceStrategy(int maxNrOfRetries, Duration withinTimeRange, Function<Throwable, Directive> function) {
super(maxNrOfRetries, withinTimeRange, function);
Expand All @@ -51,7 +55,7 @@ public boolean handleFailure(ActorContext context, ActorRef child, Throwable cau
// }
}

private class RestcommFaultToleranceDecider implements Function<Throwable, SupervisorStrategy.Directive> {
private static class RestcommFaultToleranceDecider implements Function<Throwable, SupervisorStrategy.Directive> {

@Override
// - 2nd the Supervisor strategy will execute the Decider apply() to check what to do with the exception
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2014, Telestax Inc and individual contributors
* by the @authors tag.
*
* This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

package org.restcomm.connect.commons.faulttolerance;

import akka.actor.SupervisorStrategy;
import akka.actor.UntypedActor;

/**
* @author [email protected] (Oleg Agafonov)
*/
public abstract class RestcommUntypedActor extends UntypedActor {

@Override
public SupervisorStrategy supervisorStrategy() {
return RestcommSupervisorStrategy.getStrategy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
import org.junit.Test;
import org.restcomm.connect.commons.faulttolerance.tool.ActorCreatingThread;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;

/**
* @author mariafarooq
Expand Down Expand Up @@ -46,7 +44,7 @@ public static void beforeClass() throws Exception {
actorFailureCount = new AtomicInteger();
}

@Test
@Test
public void testCreateSampleAkkaActor() throws ConfigurationException, MalformedURLException, UnknownHostException, InterruptedException {
ExecutorService executor = Executors.newFixedThreadPool(nThreads);
for (int i = 0; i < THREAD_COUNT; i++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
package org.restcomm.connect.commons.faulttolerance.tool;

import static akka.pattern.Patterns.ask;

import java.util.concurrent.TimeUnit;

import akka.actor.ActorSystem;
import org.restcomm.connect.commons.faulttolerance.SupervisorActorCreationStressTest;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
import akka.event.Logging;
import akka.event.LoggingAdapter;
import scala.concurrent.Await;
import scala.concurrent.duration.Duration;
import org.restcomm.connect.commons.faulttolerance.RestcommUntypedActor;
import org.restcomm.connect.commons.faulttolerance.SupervisorActorCreationStressTest;

/**
* MyUntypedActor represent a restcomm-connect class that request supervisor to create actor for it
*
* @author mariafarooq
*
*/
public class MyUntypedActor extends UntypedActor {
public class MyUntypedActor extends RestcommUntypedActor {
private LoggingAdapter logger = Logging.getLogger(getContext().system(), this);

private final ActorSystem system;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.restcomm.connect.commons.faulttolerance.tool;

import akka.actor.UntypedActor;
import org.restcomm.connect.commons.faulttolerance.RestcommUntypedActor;

/**
* SampleActor: a simple actor to be created
*
* @author mariafarooq
*
*/
public class SimpleActor extends UntypedActor {
public class SimpleActor extends RestcommUntypedActor {

public SimpleActor(){
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,17 @@
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.testkit.JavaTestKit;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.restcomm.connect.commons.faulttolerance.RestcommUntypedActor;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.*;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.restcomm.connect.commons.patterns.Observe;
import org.restcomm.connect.commons.patterns.Observing;
import org.restcomm.connect.commons.patterns.StopObserving;
import org.restcomm.connect.commons.patterns.TooManyObserversException;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
* @author [email protected] (Thomas Quintana)
Expand Down Expand Up @@ -108,7 +105,7 @@ public void testTooManyObserversException() {
private static final class BroadcastHelloWorld {
}

private static final class ObservableActor extends UntypedActor {
private static final class ObservableActor extends RestcommUntypedActor {
private final List<ActorRef> listeners;

@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@
package org.restcomm.connect.email;

import akka.actor.ActorRef;
import akka.actor.UntypedActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;
import org.apache.commons.configuration.Configuration;
import org.restcomm.connect.email.api.EmailRequest;
import org.restcomm.connect.email.api.EmailResponse;
import org.restcomm.connect.email.api.Mail;
import org.restcomm.connect.commons.faulttolerance.RestcommUntypedActor;
import org.restcomm.connect.commons.patterns.Observe;
import org.restcomm.connect.commons.patterns.Observing;
import org.restcomm.connect.commons.patterns.StopObserving;
import org.restcomm.connect.email.api.EmailRequest;
import org.restcomm.connect.email.api.EmailResponse;
import org.restcomm.connect.email.api.Mail;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
Expand All @@ -41,13 +42,12 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.mail.NoSuchProviderException;


/**
* @author [email protected] (Lefteris Banos)
*/
public class EmailService extends UntypedActor {
public class EmailService extends RestcommUntypedActor {

final LoggingAdapter logger = Logging.getLogger(getContext().system(), this);
private final List<ActorRef> observers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
package org.restcomm.connect.fax;

import akka.actor.ActorRef;
import akka.actor.UntypedActor;

import java.io.File;
import java.net.URI;
import java.net.URLConnection;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import org.apache.commons.configuration.Configuration;
import org.apache.http.Header;
import org.apache.http.HttpHeaders;
Expand All @@ -45,11 +37,18 @@
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.restcomm.connect.commons.faulttolerance.RestcommUntypedActor;

import java.io.File;
import java.net.URI;
import java.net.URLConnection;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

/**
* @author [email protected] (Thomas Quintana)
*/
public final class InterfaxService extends UntypedActor {
public final class InterfaxService extends RestcommUntypedActor {
private static final String url = "https://rest.interfax.net/outbound/faxes?faxNumber=";

private final TrustStrategy strategy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,8 @@
import java.util.ArrayList;
import java.util.List;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
import static javax.ws.rs.core.MediaType.APPLICATION_XML_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.CONFLICT;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static javax.ws.rs.core.MediaType.*;
import static javax.ws.rs.core.Response.Status.*;
import static javax.ws.rs.core.Response.ok;
import static javax.ws.rs.core.Response.status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.commons.configuration.Configuration;
import org.apache.log4j.Logger;
import org.joda.time.DateTime;
import org.restcomm.connect.commons.faulttolerance.RestcommUntypedActor;
import org.restcomm.connect.commons.patterns.Observe;
import org.restcomm.connect.commons.patterns.Observing;
import org.restcomm.connect.commons.patterns.StopObserving;
Expand All @@ -33,10 +34,7 @@
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
import static javax.ws.rs.core.MediaType.APPLICATION_XML_TYPE;
import static javax.ws.rs.core.MediaType.*;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
import static javax.ws.rs.core.Response.ok;
Expand Down Expand Up @@ -241,7 +239,7 @@ public UntypedActor create() throws Exception {
return system.actorOf(props);
}

private final class EmailSessionObserver extends UntypedActor {
private final class EmailSessionObserver extends RestcommUntypedActor {
public EmailSessionObserver() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.restcomm.connect.commons.annotations.concurrency.NotThreadSafe;
import org.restcomm.connect.commons.configuration.RestcommConfiguration;
import org.restcomm.connect.commons.dao.Sid;
import org.restcomm.connect.commons.faulttolerance.RestcommUntypedActor;
import org.restcomm.connect.commons.patterns.Observe;
import org.restcomm.connect.dao.DaoManager;
import org.restcomm.connect.dao.SmsMessagesDao;
Expand Down Expand Up @@ -77,13 +78,8 @@
import java.util.concurrent.TimeUnit;

import static akka.pattern.Patterns.ask;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
import static javax.ws.rs.core.MediaType.APPLICATION_XML_TYPE;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static javax.ws.rs.core.MediaType.*;
import static javax.ws.rs.core.Response.Status.*;
import static javax.ws.rs.core.Response.ok;
import static javax.ws.rs.core.Response.status;

Expand Down Expand Up @@ -391,7 +387,7 @@ public UntypedActor create() throws Exception {
return system.actorOf(props);
}

private final class SmsSessionObserver extends UntypedActor {
private final class SmsSessionObserver extends RestcommUntypedActor {
public SmsSessionObserver() {
super();
}
Expand Down
Loading

0 comments on commit 69b20b7

Please sign in to comment.