package sg.ncl.service.telemetry.logic;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import sg.ncl.adapter.deterlab.AdapterDeterLab;
import sg.ncl.service.telemetry.domain.NodeType;
import sg.ncl.service.telemetry.domain.TelemetryService;

import javax.inject.Inject;
import javax.validation.constraints.NotNull;

/**
 * Created by dcsyeoty on 26-Oct-16.
 */
@Service
@Slf4j
public class TelemetryServiceImpl implements TelemetryService {

    private final AdapterDeterLab adapterDeterLab;

    @Inject
    TelemetryServiceImpl(@NotNull final AdapterDeterLab adapterDeterLab) {
        this.adapterDeterLab = adapterDeterLab;
    }

    @Override
    public String getNodes(NodeType nodeType) {
        if (nodeType.equals(NodeType.FREE)) {
            return adapterDeterLab.getFreeNodes();
        } else {
            return adapterDeterLab.getTotalNodes();
        }
    }

    /**
     * Retrieves the number of logged in users at the current time
     * @return 0 if the number of logged in users is empty or error
     */
    @Override
    public String getLoggedInUsersCount() {
        return adapterDeterLab.getLoggedInUsersCount();
    }

    @Override
    public String getRunningExperimentsCount() {
        return adapterDeterLab.getRunningExperimentsCount();
    }
}

@@ -1173,32 +1173,191 @@
 Count();%0A    %7D%0A%0A
+    /**%0A     * Retrieves the number of running experiments at the current time%0A     * @return 0 if the number of running experiments is empty or error%0A     */%0A
     @Override%0A  

add comment