Example usage for org.joda.time DateTimeZone equals

List of usage examples for org.joda.time DateTimeZone equals

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone equals.

Prototype

public abstract boolean equals(Object object);

Source Link

Document

Compare this datetime zone with another.

Usage

From source file:com.facebook.presto.hive.HiveMetadataFactory.java

License:Apache License

public HiveMetadataFactory(HiveConnectorId connectorId, ExtendedHiveMetastore metastore,
        HdfsEnvironment hdfsEnvironment, HivePartitionManager partitionManager, DateTimeZone timeZone,
        int maxConcurrentFileRenames, boolean allowCorruptWritesForTesting, boolean respectTableFormat,
        boolean skipDeletionForAlter, boolean bucketWritingEnabled, HiveStorageFormat defaultStorageFormat,
        long perTransactionCacheMaximumSize, TypeManager typeManager, LocationService locationService,
        TableParameterCodec tableParameterCodec, JsonCodec<PartitionUpdate> partitionUpdateCodec,
        ExecutorService executorService, TypeTranslator typeTranslator, String prestoVersion) {
    this.connectorId = requireNonNull(connectorId, "connectorId is null").toString();

    this.allowCorruptWritesForTesting = allowCorruptWritesForTesting;
    this.respectTableFormat = respectTableFormat;
    this.skipDeletionForAlter = skipDeletionForAlter;
    this.bucketWritingEnabled = bucketWritingEnabled;
    this.defaultStorageFormat = requireNonNull(defaultStorageFormat, "defaultStorageFormat is null");
    this.perTransactionCacheMaximumSize = perTransactionCacheMaximumSize;

    this.metastore = requireNonNull(metastore, "metastore is null");
    this.hdfsEnvironment = requireNonNull(hdfsEnvironment, "hdfsEnvironment is null");
    this.partitionManager = requireNonNull(partitionManager, "partitionManager is null");
    this.timeZone = requireNonNull(timeZone, "timeZone is null");
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
    this.locationService = requireNonNull(locationService, "locationService is null");
    this.tableParameterCodec = requireNonNull(tableParameterCodec, "tableParameterCodec is null");
    this.partitionUpdateCodec = requireNonNull(partitionUpdateCodec, "partitionUpdateCodec is null");
    this.typeTranslator = requireNonNull(typeTranslator, "typeTranslator is null");
    this.prestoVersion = requireNonNull(prestoVersion, "prestoVersion is null");

    if (!allowCorruptWritesForTesting && !timeZone.equals(DateTimeZone.getDefault())) {
        log.warn("Hive writes are disabled. "
                + "To write data to Hive, your JVM timezone must match the Hive storage timezone. "
                + "Add -Duser.timezone=%s to your JVM arguments", timeZone.getID());
    }/*from ww  w.j  a  v  a 2s  .  c o m*/

    renameExecution = new BoundedExecutor(executorService, maxConcurrentFileRenames);
}

From source file:io.prestosql.plugin.hive.HiveMetadataFactory.java

License:Apache License

public HiveMetadataFactory(ExtendedHiveMetastore metastore, HdfsEnvironment hdfsEnvironment,
        HivePartitionManager partitionManager, DateTimeZone timeZone, int maxConcurrentFileRenames,
        boolean allowCorruptWritesForTesting, boolean skipDeletionForAlter, boolean skipTargetCleanupOnRollback,
        boolean writesToNonManagedTablesEnabled, boolean createsOfNonManagedTablesEnabled,
        long perTransactionCacheMaximumSize, int maxPartitions, TypeManager typeManager,
        LocationService locationService, TableParameterCodec tableParameterCodec,
        JsonCodec<PartitionUpdate> partitionUpdateCodec, ExecutorService executorService,
        TypeTranslator typeTranslator, String prestoVersion) {
    this.allowCorruptWritesForTesting = allowCorruptWritesForTesting;
    this.skipDeletionForAlter = skipDeletionForAlter;
    this.skipTargetCleanupOnRollback = skipTargetCleanupOnRollback;
    this.writesToNonManagedTablesEnabled = writesToNonManagedTablesEnabled;
    this.createsOfNonManagedTablesEnabled = createsOfNonManagedTablesEnabled;
    this.perTransactionCacheMaximumSize = perTransactionCacheMaximumSize;

    this.metastore = requireNonNull(metastore, "metastore is null");
    this.hdfsEnvironment = requireNonNull(hdfsEnvironment, "hdfsEnvironment is null");
    this.partitionManager = requireNonNull(partitionManager, "partitionManager is null");
    this.timeZone = requireNonNull(timeZone, "timeZone is null");
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
    this.locationService = requireNonNull(locationService, "locationService is null");
    this.tableParameterCodec = requireNonNull(tableParameterCodec, "tableParameterCodec is null");
    this.partitionUpdateCodec = requireNonNull(partitionUpdateCodec, "partitionUpdateCodec is null");
    this.typeTranslator = requireNonNull(typeTranslator, "typeTranslator is null");
    this.prestoVersion = requireNonNull(prestoVersion, "prestoVersion is null");
    this.maxPartitions = maxPartitions;

    if (!allowCorruptWritesForTesting && !timeZone.equals(DateTimeZone.getDefault())) {
        log.warn("Hive writes are disabled. "
                + "To write data to Hive, your JVM timezone must match the Hive storage timezone. "
                + "Add -Duser.timezone=%s to your JVM arguments", timeZone.getID());
    }/*from  w ww. j  av  a  2 s .c  o  m*/

    renameExecution = new BoundedExecutor(executorService, maxConcurrentFileRenames);
}

From source file:net.danlew.android.joda.ZoneInfoCompiler.java

License:Apache License

/**
 * Returns a map of ids to DateTimeZones.
 *
 * @param outputDir optional directory to write compiled data files to
 * @param sources optional list of source files to parse
 *//*  ww w  .  jav a2s .  c  o  m*/
public Map<String, DateTimeZone> compile(File outputDir, File[] sources) throws IOException {
    if (sources != null) {
        for (int i = 0; i < sources.length; i++) {
            BufferedReader in = new BufferedReader(new FileReader(sources[i]));
            parseDataFile(in);
            in.close();
        }
    }

    if (outputDir != null) {
        if (!outputDir.exists()) {
            if (!outputDir.mkdirs()) {
                throw new IOException(
                        "Destination directory doesn't exist and cannot be created: " + outputDir);
            }
        }
        if (!outputDir.isDirectory()) {
            throw new IOException("Destination is not a directory: " + outputDir);
        }
    }

    Map<String, DateTimeZone> map = new TreeMap<String, DateTimeZone>();

    System.out.println("Writing zoneinfo files");
    for (int i = 0; i < iZones.size(); i++) {
        Zone zone = iZones.get(i);
        DateTimeZoneBuilder builder = new DateTimeZoneBuilder();
        zone.addToBuilder(builder, iRuleSets);
        final DateTimeZone original = builder.toDateTimeZone(zone.iName, true);
        DateTimeZone tz = original;
        if (test(tz.getID(), tz)) {
            map.put(tz.getID(), tz);
            if (outputDir != null) {
                String fileName = ResUtils.getTzResource(tz.getID());
                if (ZoneInfoCompiler.verbose()) {
                    System.out.println("Writing " + fileName);
                }
                File file = new File(outputDir, fileName);
                if (!file.getParentFile().exists()) {
                    file.getParentFile().mkdirs();
                }
                OutputStream out = new FileOutputStream(file);
                try {
                    builder.writeTo(zone.iName, out);
                } finally {
                    out.close();
                }

                // Test if it can be read back.
                InputStream in = new FileInputStream(file);
                DateTimeZone tz2 = DateTimeZoneBuilder.readFrom(in, tz.getID());
                in.close();

                if (!original.equals(tz2)) {
                    System.out.println("*e* Error in " + tz.getID() + ": Didn't read properly from file");
                }
            }
        }
    }

    for (int pass = 0; pass < 2; pass++) {
        for (int i = 0; i < iLinks.size(); i += 2) {
            String id = iLinks.get(i);
            String alias = iLinks.get(i + 1);
            DateTimeZone tz = map.get(id);
            if (tz == null) {
                if (pass > 0) {
                    System.out.println("Cannot find time zone '" + id + "' to link alias '" + alias + "' to");
                }
            } else {
                map.put(alias, tz);
            }
        }
    }

    if (outputDir != null) {
        System.out.println("Writing " + ResUtils.getZoneInfoMapResource());
        File file = new File(outputDir, ResUtils.getZoneInfoMapResource());
        if (!file.getParentFile().exists()) {
            file.getParentFile().mkdirs();
        }

        OutputStream out = new FileOutputStream(file);
        DataOutputStream dout = new DataOutputStream(out);
        try {
            // Sort and filter out any duplicates that match case.
            Map<String, DateTimeZone> zimap = new TreeMap<String, DateTimeZone>(String.CASE_INSENSITIVE_ORDER);
            zimap.putAll(map);
            writeZoneInfoMap(dout, zimap);
        } finally {
            dout.close();
        }
    }

    return map;
}