* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import com.datastax.driver.core.Row;
/**
- * LocateDAO manages credentials.
+ * LocateDAO manages credentials.
* @author Jonathan
* Date: 10/11/17
*/
public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
public static final String TABLE = "locate";
private AbsCassDAO<AuthzTrans, Data>.PSInfo psName;
-
+
public LocateDAO(AuthzTrans trans, Cluster cluster, String keyspace) throws APIException, IOException {
super(trans, LocateDAO.class.getSimpleName(),cluster, keyspace, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
super(trans, LocateDAO.class.getSimpleName(), adao, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
}
-
+
public static final int KEYLIMIT = 3;
public static class Data implements Bytification {
-
+
public String name;
public String hostname;
public int port;
}
return subprotocol;
}
-
+
@Override
public ByteBuffer bytify() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
LocateLoader.deflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
LocateLoader.deflt.unmarshal(this, toDIS(bb));
}
- public Data copy() {
- Data out = new Data();
+ public Data copy() {
+ Data out = new Data();
out.name = name;
out.hostname = hostname;
out.port = port;
out.subprotocol = new HashSet<>();
out.subprotocol.addAll(subprotocol);
out.port_key = port_key;
- return out;
- }
+ return out;
+ }
}
private static class LocateLoader extends Loader<Data> implements Streamer<Data>{
public static final int MAGIC=85102934;
public static final int VERSION=1;
- public static final int BUFF_SIZE=48; // Note:
-
+ public static final int BUFF_SIZE=48; // Note:
+
public static final LocateLoader deflt = new LocateLoader(KEYLIMIT);
public LocateLoader(int keylimit) {
super(keylimit);
writeString(os,s);
}
}
-
+
writeString(os,data.port_key==null?"":data.port_key.toString());
}
data.latitude = is.readFloat();
data.longitude = is.readFloat();
data.protocol = readString(is,buff);
-
+
int size = is.readInt();
data.subprotocol = new HashSet<>(size);
for (int i=0;i<size;++i) {
}
}
}
-
+
public Result<List<LocateDAO.Data>> readByName(AuthzTrans trans, String service) {
return psName.read(trans, "Read By Name", new Object[] {service});
}
psName = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE name = ?", new LocateLoader(1),readConsistency);
}
-
+
/**
* Log Modification statements to History
*