// Path: src/main/java/io/playpen/core/coordinator/network/authenticator/IAuthenticator.java
// public interface IAuthenticator {
//     String getName();
//     boolean hasAccess(Commands.BaseCommand command, TransactionInfo info, LocalCoordinator from);
// }
// 
// Path: src/main/java/io/playpen/core/networking/TransactionInfo.java
// @Data
// public class TransactionInfo {
//     private String id;
// 
//     private String target = null;
// 
//     private Protocol.Transaction transaction = null;
// 
//     private ITransactionListener handler = null;
// 
//     private ScheduledFuture cancelTask = null;
// 
//     private boolean done = false;
// }
// 
// Path: src/main/java/io/playpen/core/p3/P3Package.java
// @Data
// @Log4j2
// public class P3Package {
// 
//     @Data
//     public static class PackageStepConfig {
//         IPackageStep step;
//         JSONObject config;
//     }
// 
//     @Data
//     public static class P3PackageInfo {
//         private String id;
//         private String version;
// 
//         @Override
//         public boolean equals(Object other) {
//             if(other instanceof P3PackageInfo) {
//                 P3PackageInfo o = (P3PackageInfo)other;
//                 return id.equals(o.getId()) && version.equals(o.getVersion());
//             }
// 
//             return false;
//         }
// 
//         @Override
//         public int hashCode() {
//             return id.hashCode() ^ version.hashCode();
//         }
//     }
// 
//     private String localPath;
// 
//     private boolean resolved;
// 
//     // ALWAYS call calculateChecksum() before using this!
//     private String checksum = null;
// 
//     private String id;
// 
//     private String version;
// 
//     private List<P3Package> dependencies = new ArrayList<>();
// 
//     private Map<String, Integer> resources = new HashMap<>();
// 
//     private Set<String> attributes = new HashSet<>();
// 
//     private Map<String, String> strings = new HashMap<>();
// 
//     private List<PackageStepConfig> provisionSteps = new ArrayList<>();
// 
//     private List<PackageStepConfig> executionSteps = new ArrayList<>();
// 
//     private List<PackageStepConfig> shutdownSteps = new ArrayList<>();
// 
//     /**
//      * Checks to make sure required fields are filled. Does not check resolution status!
//      */
//     public boolean validate() {
//         if(id == null || id.isEmpty() || version == null || version.isEmpty())
//             return false;
// 
//         for(P3Package p3 : dependencies)
//         {
//             if(!p3.validate())
//                 return false;
//         }
// 
//         return true;
//     }
// 
//     public void calculateChecksum() throws PackageException {
//         calculateChecksum(false);
//     }
// 
//     public synchronized void calculateChecksum(boolean force) throws PackageException {
//         if (!force && checksum != null)
//             return;
// 
//         if (!resolved)
//             throw new PackageException("Cannot calculate checksum on unresolved package");
// 
//         if (localPath == null || localPath.isEmpty())
//             throw new PackageException("Cannot calculate checksum on package with invalid localPath");
// 
//         log.debug("Recalculating checksum on " + id + " (" + version + ")");
// 
//         try {
//             checksum = AuthUtils.createPackageChecksum(localPath);
//         } catch (IOException e) {
//             throw new PackageException("Unable to calculate checksum from package file", e);
//         }
//     }
// }


import io.netty.channel.Channel;
import io.playpen.core.coordinator.network.authenticator.IAuthenticator;
import io.playpen.core.networking.TransactionInfo;
import io.playpen.core.p3.P3Package;
import io.playpen.core.protocol.Commands;
import lombok.Data;
import lombok.extern.log4j.Log4j2;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
package io.playpen.core.coordinator.network;



@Data
@Log4j2
public class LocalCoordinator {
    private String uuid;

    private String key;

    private String name;

    private String keyName = "";

    private Map<String, Integer> resources = new ConcurrentHashMap<>();

    private Set<String> attributes = new ConcurrentSkipListSet<>();

    private Map<String, Server> servers = new ConcurrentHashMap<>();

    private Channel channel = null;

    private boolean enabled = false;

    /**
     * Setting this to true will prevent automatic selection of this coordinator for provisioning operations.
     * This must be manually set and unset, but will also reset if the network coordinator is restarted.
     */
    private boolean restricted = false;

// Path: src/main/java/io/playpen/core/coordinator/network/authenticator/IAuthenticator.java
// public interface IAuthenticator {
//     String getName();
//     boolean hasAccess(Commands.BaseCommand command, TransactionInfo info, LocalCoordinator from);
// }
// 
// Path: src/main/java/io/playpen/core/networking/TransactionInfo.java
// @Data
// public class TransactionInfo {
//     private String id;
// 
//     private String target = null;
// 
//     private Protocol.Transaction transaction = null;
// 
//     private ITransactionListener handler = null;
// 
//     private ScheduledFuture cancelTask = null;
// 
//     private boolean done = false;
// }
// 
// Path: src/main/java/io/playpen/core/p3/P3Package.java
// @Data
// @Log4j2
// public class P3Package {
// 
//     @Data
//     public static class PackageStepConfig {
//         IPackageStep step;
//         JSONObject config;
//     }
// 
//     @Data
//     public static class P3PackageInfo {
//         private String id;
//         private String version;
// 
//         @Override
//         public boolean equals(Object other) {
//             if(other instanceof P3PackageInfo) {
//                 P3PackageInfo o = (P3PackageInfo)other;
//                 return id.equals(o.getId()) && version.equals(o.getVersion());
//             }
// 
//             return false;
//         }
// 
//         @Override
//         public int hashCode() {
//             return id.hashCode() ^ version.hashCode();
//         }
//     }
// 
//     private String localPath;
// 
//     private boolean resolved;
// 
//     // ALWAYS call calculateChecksum() before using this!
//     private String checksum = null;
// 
//     private String id;
// 
//     private String version;
// 
//     private List<P3Package> dependencies = new ArrayList<>();
// 
//     private Map<String, Integer> resources = new HashMap<>();
// 
//     private Set<String> attributes = new HashSet<>();
// 
//     private Map<String, String> strings = new HashMap<>();
// 
//     private List<PackageStepConfig> provisionSteps = new ArrayList<>();
// 
//     private List<PackageStepConfig> executionSteps = new ArrayList<>();
// 
//     private List<PackageStepConfig> shutdownSteps = new ArrayList<>();
// 
//     /**
//      * Checks to make sure required fields are filled. Does not check resolution status!
//      */
//     public boolean validate() {
//         if(id == null || id.isEmpty() || version == null || version.isEmpty())
//             return false;
// 
//         for(P3Package p3 : dependencies)
//         {
//             if(!p3.validate())
//                 return false;
//         }
// 
//         return true;
//     }
// 
//     public void calculateChecksum() throws PackageException {
//         calculateChecksum(false);
//     }
// 
//     public synchronized void calculateChecksum(boolean force) throws PackageException {
//         if (!force && checksum != null)
//             return;
// 
//         if (!resolved)
//             throw new PackageException("Cannot calculate checksum on unresolved package");
// 
//         if (localPath == null || localPath.isEmpty())
//             throw new PackageException("Cannot calculate checksum on package with invalid localPath");
// 
//         log.debug("Recalculating checksum on " + id + " (" + version + ")");
// 
//         try {
//             checksum = AuthUtils.createPackageChecksum(localPath);
//         } catch (IOException e) {
//             throw new PackageException("Unable to calculate checksum from package file", e);
//         }
//     }
// }


// Path: src/main/java/io/playpen/core/coordinator/network/LocalCoordinator.java
import io.netty.channel.Channel;
import io.playpen.core.coordinator.network.authenticator.IAuthenticator;
import io.playpen.core.networking.TransactionInfo;
import io.playpen.core.p3.P3Package;
import io.playpen.core.protocol.Commands;
import lombok.Data;
import lombok.extern.log4j.Log4j2;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;

package io.playpen.core.coordinator.network;



@Data
@Log4j2
public class LocalCoordinator {
    private String uuid;

    private String key;

    private String name;

    private String keyName = "";

    private Map<String, Integer> resources = new ConcurrentHashMap<>();

    private Set<String> attributes = new ConcurrentSkipListSet<>();

    private Map<String, Server> servers = new ConcurrentHashMap<>();

    private Channel channel = null;

    private boolean enabled = false;

    /**
     * Setting this to true will prevent automatic selection of this coordinator for provisioning operations.
     * This must be manually set and unset, but will also reset if the network coordinator is restarted.
     */
    private boolean restricted = false;

    private List<IAuthenticator> authenticators = new ArrayList<>();