Mercurial > hg > thermostat-ng > agent
changeset 2703:c107bad9a308
Cleanup of storage-core: remove unused code
review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-June/023878.html
reviwed-by: jerboaa
author | Mario Torre <neugens.limasoftware@gmail.com> |
---|---|
date | Fri, 23 Jun 2017 15:41:47 +0200 |
parents | 459d991a6ade |
children | 54b6408e08b6 |
files | storage/core/src/main/java/com/redhat/thermostat/storage/config/AuthenticationConfiguration.java storage/core/src/main/java/com/redhat/thermostat/storage/core/AuthToken.java storage/core/src/main/java/com/redhat/thermostat/storage/core/BasicBatchCursor.java storage/core/src/main/java/com/redhat/thermostat/storage/core/Countable.java storage/core/src/main/java/com/redhat/thermostat/storage/core/Cursor.java storage/core/src/main/java/com/redhat/thermostat/storage/core/DescriptorParsingException.java storage/core/src/main/java/com/redhat/thermostat/storage/core/IllegalDescriptorException.java storage/core/src/main/java/com/redhat/thermostat/storage/core/IllegalPatchException.java storage/core/src/main/java/com/redhat/thermostat/storage/model/AggregateCount.java storage/core/src/main/java/com/redhat/thermostat/storage/model/AggregateCursor.java storage/core/src/main/java/com/redhat/thermostat/storage/model/AggregateResult.java storage/core/src/main/java/com/redhat/thermostat/storage/model/DiscreteTimeData.java storage/core/src/main/java/com/redhat/thermostat/storage/model/DistinctResult.java storage/core/src/main/java/com/redhat/thermostat/storage/model/IntervalTimeData.java storage/core/src/test/java/com/redhat/thermostat/storage/core/BasicBatchCursorTest.java storage/core/src/test/java/com/redhat/thermostat/storage/model/AggregateCountTest.java storage/core/src/test/java/com/redhat/thermostat/storage/model/AggregateCursorTest.java |
diffstat | 17 files changed, 0 insertions(+), 1178 deletions(-) [+] |
line wrap: on
line diff
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/config/AuthenticationConfiguration.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.config; - -public interface AuthenticationConfiguration { - - String getUsername(); - char[] getPassword(); -} -
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/AuthToken.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - - -package com.redhat.thermostat.storage.core; - -import java.util.Arrays; - - -public class AuthToken { - - private final byte[] token; - private final byte[] clientToken; - - public AuthToken(byte[] token, byte[] clientToken) { - this.token = token; - this.clientToken = clientToken; - } - - public byte[] getToken() { - return token; - } - - public byte[] getClientToken() { - return clientToken; - } - - @Override - public String toString() { - return "AuthToken: client-token: " + Arrays.toString(clientToken) + ", token: " + Arrays.toString(token); - } -} -
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/BasicBatchCursor.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.core; - -import com.redhat.thermostat.storage.model.Pojo; - -public abstract class BasicBatchCursor<T extends Pojo> implements Cursor<T> { - - private int batchSize = Cursor.DEFAULT_BATCH_SIZE; - - @Override - public void setBatchSize(int n) throws IllegalArgumentException { - if (n <= 0) { - throw new IllegalArgumentException("Batch size must be > 0"); - } - this.batchSize = n; - } - - @Override - public int getBatchSize() { - return this.batchSize; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - -}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Countable.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.core; - -public interface Countable { - - public long getCount(); - -} -
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Cursor.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.core; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -import com.redhat.thermostat.storage.model.Pojo; - -/** - * Allows traversing over objects obtained from {@link Storage}. - * - * @see PreparedStatement#executeQuery() - */ -public interface Cursor<T extends Pojo> extends Iterator<T> { - - public static final int DEFAULT_BATCH_SIZE = 100; - - /** - * <p> - * Sets the configured batch size when retrieving more elements from the - * database. That is, no more elements will be loaded into memory than the - * configured batch size. Note that the new batch size will only take effect - * once the current batch is exhausted. - * </p> - * <p> - * The default batch size is 100. - * </p> - * - * @param n - * The number of results to fetch from storage in a single batch. - * @return A cursor with the configured batch size. - * @throws IllegalArgumentException - * If {@code n} is < 1 - */ - void setBatchSize(int n) throws IllegalArgumentException; - - /** - * - * @return The configured batch size set via {@link setBatchSize} or - * {@link BatchCursor#DEFAULT_BATCH_SIZE} if it was never set - * explicitly. - */ - int getBatchSize(); - - /** - * @return {@code true} if there are more elements, {@code false} otherwise. - * - * @throws StorageException - * If there was a problem with underlying {@link Storage}. - */ - boolean hasNext(); - - /** - * Retrieves the next element from the result set. Users are advised to call - * {@link #hasNext()} prior to calling this method. - * - * @return <p> - * The next element of the result set. {@code null} if there is no - * next element. - * </p> - * <p> - * <strong>Please note: </strong> This will change with the next - * release. In the next major release a - * {@link NoSuchElementException} will be thrown if there is no next - * element. I.e. {@link #hasNext()} returns {@code false}, but - * {@code next()} is still being called. - * </p> - * - * @throws StorageException - * If there was a problem with underlying {@link Storage}. - */ - T next(); - -} -
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/DescriptorParsingException.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.core; - -@SuppressWarnings("serial") -public class DescriptorParsingException extends Exception { - - public DescriptorParsingException(String msg) { - super(msg); - } -}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/IllegalDescriptorException.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.core; - -/** - * Thrown if a prepared statement descriptor was refused by the storage endpoint. - */ -@SuppressWarnings("serial") -public class IllegalDescriptorException extends DescriptorParsingException { - - private final String failedDescriptor; - - public IllegalDescriptorException(String errorMsg, String strDescriptor) { - super(errorMsg); - this.failedDescriptor = strDescriptor; - } - - public String getFailedDescriptor() { - return failedDescriptor; - } - -} -
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/IllegalPatchException.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.core; - -/** - * Thrown if a prepared statement was attempted to patch, which resulted in - * NPEs or a type mismatch for some of the free variables. - * - */ -@SuppressWarnings("serial") -public class IllegalPatchException extends Exception { - - public IllegalPatchException(Throwable cause) { - super(cause); - } -} -
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/AggregateCount.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.model; - -import java.util.Objects; - -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Entity; -import com.redhat.thermostat.storage.core.Persist; - -/** - * Model class for aggregate counts. - * - */ -@Entity -public class AggregateCount implements AggregateResult { - - private long count; - - @Persist - public long getCount() { - return count; - } - - @Persist - public void setCount(long count) { - this.count = count; - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof AggregateCount)) { - return false; - } - AggregateCount o = (AggregateCount)other; - return this.getCount() == o.getCount(); - } - - @Override - public int hashCode() { - return Objects.hash(getCount()); - } - - @SuppressWarnings("unchecked") - public <T extends Pojo> Cursor<T> getCursor() { - return (Cursor<T>)new AggregateCursor<>(this); - } - -} -
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/AggregateCursor.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.model; - -import java.util.logging.Logger; - -import com.redhat.thermostat.common.utils.LoggingUtils; -import com.redhat.thermostat.storage.core.BasicBatchCursor; - -import java.util.NoSuchElementException; - -/** - * A cursor which returns true on {@link #hasNext()} once and only once. - * {@link #next()} will return the instance given when the cursor was - * constructed. - * - * @param <T> - */ -class AggregateCursor<T extends Pojo> extends BasicBatchCursor<T> { - - private static final Logger logger = LoggingUtils.getLogger(AggregateCursor.class); - private boolean available = true; - private final T result; - - AggregateCursor(T value) { - this.result = value; - } - - @Override - public boolean hasNext() { - return available; - } - - @Override - public T next() { - if (available) { - available = false; - return result; - } else { - throw new NoSuchElementException(); - } - } - -}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/AggregateResult.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.model; - -/** - * Super type for aggregate results. - * Marker only. - * - */ -public interface AggregateResult extends Pojo { - -} -
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/DiscreteTimeData.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.model; - -/** - * Represents a data associated with a discrete point in time - * - * @param <T> the type data associated with this point in time - */ -public class DiscreteTimeData<T> { - - private long millis; - private T data; - - public DiscreteTimeData(long millis, T data) { - this.millis = millis; - this.data = data; - } - - public long getTimeInMillis() { - return millis; - } - - public T getData() { - return data; - } - -} -
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/DistinctResult.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.model; - -import com.redhat.thermostat.storage.core.Cursor; -import com.redhat.thermostat.storage.core.Entity; -import com.redhat.thermostat.storage.core.Key; -import com.redhat.thermostat.storage.core.Persist; - -/** - * Model class for aggregated query results based on distinct values - * of a key. - * - */ -@Entity -public class DistinctResult implements AggregateResult { - - private String[] values; - private Key<?> key; - - @Persist - public String[] getValues() { - return values; - } - - @Persist - public void setValues(String[] values) { - this.values = values; - } - - @Persist - public Key<?> getKey() { - return key; - } - - @Persist - public void setKey(Key<?> key) { - this.key = key; - } - - @SuppressWarnings("unchecked") - public <T extends Pojo> Cursor<T> getCursor() { - return (Cursor<T>) new AggregateCursor<>(this); - } - -}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/IntervalTimeData.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.model; - -import java.util.Objects; - -public class IntervalTimeData<T> { - - private long start; - private long end; - private T data; - - public IntervalTimeData(long start, long end, T data) { - this.start = start; - this.end = end; - this.data = data; - } - - public long getStartTimeInMillis() { - return start; - } - - public long getEndTimeInMillis() { - return end; - } - - public T getData() { - return data; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - IntervalTimeData that = (IntervalTimeData) o; - - if (end != that.end) return false; - if (start != that.start) return false; - if (!Objects.equals(data, that.data)) return false; - - return true; - } - - @Override - public int hashCode() { - return Objects.hash(start, end, data); - } -} -
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/BasicBatchCursorTest.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.core; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import org.junit.Test; - -import com.redhat.thermostat.storage.model.Pojo; - -public class BasicBatchCursorTest { - - @Test - public void testSetBatchSize() { - BasicBatchCursor<TestPojo> cursor = new BasicBatchCursorImpl<>(); - try { - cursor.setBatchSize(-1); - fail("expected IAE for batch size of -1"); - } catch (IllegalArgumentException e) { - // pass - assertEquals("Batch size must be > 0", e.getMessage()); - } - try { - cursor.setBatchSize(0); - fail("expected IAE for batch size of 0"); - } catch (IllegalArgumentException e) { - // pass - assertEquals("Batch size must be > 0", e.getMessage()); - } - cursor.setBatchSize(Cursor.DEFAULT_BATCH_SIZE); - assertEquals(Cursor.DEFAULT_BATCH_SIZE, cursor.getBatchSize()); - } - - @Test - public void testGetBatchSize() { - BasicBatchCursor<TestPojo> cursor = new BasicBatchCursorImpl<>(); - assertEquals("should always return default if never set", Cursor.DEFAULT_BATCH_SIZE, cursor.getBatchSize()); - cursor.setBatchSize(3); - assertEquals(3, cursor.getBatchSize()); - } - - private static class BasicBatchCursorImpl<T extends Pojo> extends BasicBatchCursor<T> { - - @Override - public boolean hasNext() { - // not implemented - return false; - } - - @Override - public T next() { - // not implemented - return null; - } - - } - - private static class TestPojo implements Pojo { - // nothing - } -}
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/model/AggregateCountTest.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.model; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class AggregateCountTest { - - @Test - public void testEquals() { - AggregateCount c = new AggregateCount(); - assertTrue("should be equal to self", c.equals(c)); - c.setCount(-1); - assertTrue("should be equal to self", c.equals(c)); - AggregateCount d = new AggregateCount(); - d.setCount(-1); - assertTrue("c + d have equal count", c.equals(d)); - d.setCount(10); - assertFalse("c has count -1, d 10", c.equals(d)); - assertFalse("string is no agg-count", c.equals("foo")); - assertTrue(new AggregateCount().equals(new AggregateCount())); - } - - @Test - public void testHashCode() { - AggregateCount c = new AggregateCount(); - assertEquals(c.hashCode(), c.hashCode()); - c.setCount(-1); - assertEquals(c.hashCode(), c.hashCode()); - AggregateCount d = new AggregateCount(); - d.setCount(-1); - assertEquals(d.hashCode(), c.hashCode()); - d.setCount(100); - assertFalse(d.hashCode() == c.hashCode()); - assertFalse("foo".hashCode() == d.hashCode()); - assertEquals(new AggregateCount().hashCode(), new AggregateCount().hashCode()); - } -} -
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/model/AggregateCursorTest.java Wed Jun 21 14:09:07 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* - * Copyright 2012-2017 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.storage.model; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.NoSuchElementException; - -import org.junit.Test; - -import com.redhat.thermostat.storage.core.Cursor; - -public class AggregateCursorTest { - - @Test - public void testCursor() { - AggregateTest t = new AggregateTest(); - Cursor<AggregateTest> cursor = t.getCursor(); - assertTrue(cursor.hasNext()); - AggregateTest actual = cursor.next(); - assertSame(t, actual); - assertFalse(cursor.hasNext()); - try { - cursor.next(); - fail("Cursor should throw a NoSuchElementException!"); - } catch (NoSuchElementException e) { - // pass - } - } - - /** - * Setting the batch size for single result lists should be no-op. - * This just makes sure that nothing bad happens (no exceptions being thrown) - */ - @Test - public void testCursorBatchSize() { - AggregateTest t = new AggregateTest(); - Cursor<AggregateTest> cursor = t.getCursor(); - cursor.setBatchSize(500); - assertEquals(500, cursor.getBatchSize()); - } - - private static class AggregateTest implements AggregateResult { - - @SuppressWarnings("unchecked") - private <T extends Pojo> Cursor<T> getCursor() { - return (Cursor<T>)new AggregateCursor<>(this); - } - } -}