Package org.rhq.common.drift

Examples of org.rhq.common.drift.Headers


        File rootDir = getTempDir();
        File changeSetsDir = new File(rootDir, "changesets");
        deleteDirectory(changeSetsDir);
        changeSetsDir.mkdirs();

        Headers headers = new Headers();
        headers.setResourceId(newResource.getId());
        headers.setDriftDefinitionId(1);
        headers.setDriftDefinitionName("test-1");
        headers.setBasedir(rootDir.getAbsolutePath());
        headers.setType(COVERAGE);
        headers.setVersion(0);

        String file1Hash = sha256("test-1-file-1");

        File changeSet1 = new File(changeSetsDir, "changeset-1.txt");
        ChangeSetWriter writer = new ChangeSetWriterImpl(changeSet1, headers);
        writer.write(addedFileEntry("test/file-1", file1Hash, 56789L, 1024L));
        writer.close();

        File changeSet1Zip = new File(changeSetsDir, "changeset-1.zip");
        ZipUtil.zipFileOrDirectory(changeSet1, changeSet1Zip);

        assertTrue("Expected to find change set zip file: " + changeSet1Zip.getPath(), changeSet1Zip.exists());

        jpaDriftServer.storeChangeSet(overlord, newResource.getId(), changeSet1Zip);

        JPADriftChangeSetCriteria c = new JPADriftChangeSetCriteria();
        c.addFilterResourceId(newResource.getId());
        c.fetchDrifts(true);
        List<? extends DriftChangeSet<?>> changeSets = jpaDriftServer.findDriftChangeSetsByCriteria(overlord, c);
        assertEquals(1, changeSets.size());
        DriftChangeSet<?> changeSet = changeSets.get(0);
        assertEquals(0, changeSet.getVersion());
        assertEquals("Expected to find one entry in change set", 1, changeSet.getDrifts().size());

        DriftFile driftFile = jpaDriftServer.getDriftFile(overlord, file1Hash);
        assertNotNull(driftFile);
        assertEquals(DriftFileStatus.REQUESTED, driftFile.getStatus());

        // the second change set should report drift
        String modifiedFile1Hash = sha256("test-2-file-1-modified");
        headers.setType(DRIFT);
        headers.setVersion(1);
        File changeSet2 = new File(changeSetsDir, "changeset-2.txt");

        writer = new ChangeSetWriterImpl(changeSet2, headers);
        writer.write(changedFileEntry("test/file-1", file1Hash, modifiedFile1Hash, 56789L, 1024L));
        writer.close();
View Full Code Here


        List<FileEntry> deltaEntries, int newVersion, File oldSnapshot, File newSnapshot) throws IOException {

        ChangeSetWriter deltaWriter = null;

        try {
            Headers deltaHeaders = createHeaders(schedule, DRIFT, newVersion);
            File driftChangeSet = changeSetMgr.findChangeSet(schedule.getResourceId(), schedule.getDriftDefinition()
                .getName(), DRIFT);
            deltaWriter = changeSetMgr.getChangeSetWriter(driftChangeSet, deltaHeaders);

            summary.setDriftChangeSet(driftChangeSet);
View Full Code Here

        throws IOException {

        ChangeSetWriter newSnapshotWriter = null;

        try {
            Headers snapshotHeaders = createHeaders(schedule, COVERAGE, newVersion);
            File newSnapshot = changeSetMgr.findChangeSet(schedule.getResourceId(), schedule.getDriftDefinition()
                .getName(), COVERAGE);
            newSnapshotWriter = changeSetMgr.getChangeSetWriter(schedule.getResourceId(), snapshotHeaders);

            for (FileEntry entry : snapshotEntries) {
View Full Code Here

        List<FileEntry> snapshotEntries) throws IOException {

        ChangeSetWriter newSnapshotWriter = null;

        try {
            Headers snapshotHeaders = createHeaders(schedule, COVERAGE, 0);
            newSnapshotWriter = changeSetMgr.getChangeSetWriter(pinnedSnapshot, snapshotHeaders);

            for (FileEntry entry : snapshotEntries) {
                newSnapshotWriter.write(entry);
            }
View Full Code Here

    private String basedir(int resourceId, DriftDefinition driftDef) {
        return driftClient.getAbsoluteBaseDirectory(resourceId, driftDef).getAbsolutePath();
    }

    private Headers createHeaders(DriftDetectionSchedule schedule, DriftChangeSetCategory type, int version) {
        Headers headers = new Headers();
        headers.setResourceId(schedule.getResourceId());
        headers.setDriftDefinitionId(schedule.getDriftDefinition().getId());
        headers.setDriftDefinitionName(schedule.getDriftDefinition().getName());
        headers.setBasedir(basedir(schedule.getResourceId(), schedule.getDriftDefinition()));
        headers.setType(type);
        headers.setVersion(version);

        return headers;
    }
View Full Code Here

    protected Headers createHeaders(DriftDefinition driftDef, DriftChangeSetCategory type) {
        return createHeaders(driftDef, type, 0);
    }

    protected Headers createHeaders(DriftDefinition driftDef, DriftChangeSetCategory type, int version) {
        Headers headers = new Headers();
        headers.setResourceId(resourceId());
        headers.setDriftDefinitionId(driftDef.getId());
        headers.setDriftDefinitionName(driftDef.getName());
        headers.setBasedir(resourceDir.getAbsolutePath());
        headers.setType(type);
        headers.setVersion(version);

        return headers;
    }
View Full Code Here

        String driftDefName = "send-one-file-test";
        File serverConf = createRandomFile(resourceDir, "server.conf");
        String serverConfHash = sha256(serverConf);

        File changeSetDir = changeSetDir(driftDefName);
        Headers headers = createHeaders(driftDefName, COVERAGE);

        ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(resourceId(), headers);
        writer.write(addedFileEntry("server.conf", serverConfHash, serverConf.lastModified(), serverConf.length()));
        writer.close();
View Full Code Here

        String server1ConfHash = sha256(server1Conf);
        String server2ConfHash = sha256(server2Conf);

        File changeSetDir = changeSetDir(driftDefName);

        Headers headers = createHeaders(driftDefName, COVERAGE);

        ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(resourceId(), headers);
        writer.write(addedFileEntry("conf/server-1.conf", server1ConfHash, server1Conf.lastModified(), server1Conf
            .length()));
        writer.write(addedFileEntry("conf/server-2.conf", server2ConfHash, server2Conf.lastModified(), server2Conf
View Full Code Here

        String server1JarHash = sha256(server1Jar);
        String server2JarHash = sha256(server2Jar);

        File changeSetDir = changeSetDir(driftDefName);

        Headers headers = createHeaders(driftDefName, COVERAGE);

        ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(resourceId(), headers);
        writer.write(addedFileEntry("conf/server-1.conf", server1ConfHash, server1Conf.lastModified(), server1Conf
            .length()));
        writer.write(addedFileEntry("conf/server-2.conf", server2ConfHash, server2Conf.lastModified(), server2Conf
View Full Code Here

        String server1ConfHash = sha256(server1Conf);
        String server2ConfHash = sha256(server2Conf);

        File changeSetDir = changeSetDir(driftDefName);

        Headers headers = createHeaders(driftDefName, COVERAGE);

        ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(resourceId(), headers);
        writer.write(addedFileEntry("conf/server-1.conf", server1ConfHash, server1Conf.lastModified(), server1Conf
            .length()));
        writer.write(addedFileEntry("conf/server-2.conf", server2ConfHash, server2Conf.lastModified(), server2Conf
View Full Code Here

TOP

Related Classes of org.rhq.common.drift.Headers

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.