openvidu-server: reversed checking of COTURN Redis DB on startup

pull/88/merge
pabloFuente 2018-06-26 10:06:47 +02:00
parent ad1a8ef296
commit 35dda59124
2 changed files with 6 additions and 5 deletions

View File

@ -23,11 +23,9 @@ public class BashCoturnCredentialsService extends CoturnCredentialsService {
// No coturn installed in the host machine
log.warn("No COTURN server is installed in the host machine. Response: " + response);
log.warn("No COTURN server will be automatically configured for clients");
this.coturnAvailable = false;
} else if (response.contains("Cannot initialize Redis DB connection")) {
log.warn("Redis DB is not accesible with connection string " + this.coturnDatabaseString);
log.warn("No COTURN server will be automatically configured for clients");
this.coturnAvailable = false;
} else {
log.info("COTURN Redis DB accessible with string " + this.coturnDatabaseString);
log.info("Cleaning COTURN DB...");
@ -46,11 +44,12 @@ public class BashCoturnCredentialsService extends CoturnCredentialsService {
} else {
log.error("COTURN DB is not empty");
}
this.coturnAvailable.compareAndSet(false, true);
log.info("Using COTURN credentials service for BASH environment");
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
log.info("Using COTURN credentials service for BASH environment");
}
@Override

View File

@ -1,5 +1,7 @@
package io.openvidu.server.coturn;
import java.util.concurrent.atomic.AtomicBoolean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@ -16,7 +18,7 @@ public abstract class CoturnCredentialsService {
protected String coturnDatabaseString;
protected String trimmedCoturnDatabaseString;
protected boolean coturnAvailable = true;
protected AtomicBoolean coturnAvailable = new AtomicBoolean(false);
public CoturnCredentialsService(OpenviduConfig openviduConfig) {
this.openviduConfig = openviduConfig;
@ -29,7 +31,7 @@ public abstract class CoturnCredentialsService {
public abstract boolean deleteUser(String user);
public boolean isCoturnAvailable() {
return this.coturnAvailable;
return this.coturnAvailable.get();
}
}