Giter Club home page Giter Club logo

cfe_31's Introduction

CFE-31

This is an integration utility for scraping data from Git and sending it to CFE-18 written in Java 11. Uses Gson for JSON scraping and OkHttp for sending the data and parsing responses.

Features

  • Scrape data from predefined data structures

  • Convert data to POJOs

  • Send data to CFE-18

Documentation

See internal documentation (for now)

Limitations

  • Limited to the predetermined data structure

  • Does not check for existing duplicates on CFE-18, relies on CFE-18 to handle duplicates

How to compile

mvn clean compile

Contributing

You can involve yourself with our project by opening an issue or submitting a pull request.

Contribution requirements:

  1. All changes must be accompanied by a new or changed test. If you think testing is not required in your pull request, include a sufficient explanation as why you think so.

  2. Security checks must pass

  3. Pull requests must align with the principles and values of extreme programming.

  4. Pull requests must follow the principles of Object Thinking and Elegant Objects (EO).

Read more in our Contributing Guideline.

Contributor License Agreement

Contributors must sign Teragrep Contributor License Agreement before a pull request is accepted to organization’s repositories.

You need to submit the CLA only once. After submitting the CLA you can contribute to all Teragrep’s repositories.

cfe_31's People

Contributors

moonbow-1 avatar ronja-ui avatar

Watchers

Mikko Kortelainen avatar Strongest Number 9 avatar

cfe_31's Issues

Add more unit tests

Tests have been written for classes in the types directory, cfe-01 sub-directory still has a few classes that require them

Remove Optional<> wrappers

Description

Title
Use case or motivation behind the feature request

Optional wrappers are basically just null values, so its better to move away from them and use exceptions

Additional context

yegor

Rename classes

The "Parser" name doesn't conform into OOP naming practices, hence it should be name something like "Hub".
The parseDirs method inside the Parser class should be elevated into its own class and called PromiseList.
CFE-01 and RELP Parsers should be renamed to ...Promise (This will be a single class with a generic type parameter.

Fix errorprone warnings from compiler

Description

There are 39 warnings about error-prone code, mostly NonApiType ArrayLists and missing locale declarations.

  • Fix ArrayLists
  • Fix StringCaseLocaleUsage
  • Fix inconsistent capitalization
  • Fix ZonedDateTime.now() default timezone
  • Fix Default charset
  • Fix HidingField in CFE01GenerateFile (extends RelpGenerateFile)
  • Find out what to do with MHC exclusion in HubDirList

java package names are not standard

ID <20>
Reporter <@kortemik>

java package name should start with:
groupId+artifactId
in the case of cfe-31 it should be
fi.failsafe.lms.cfe31
i.e. package httpController; would become package fi.failsafe.lms.cfe31.httpController;
please use IDE refactor rename for the package name and it will take care of the rest.

Refactor HttpClient usage

  1. Logging

Currently sending requests only returns an HttpResponse object, which is then individually logged by the sender.

The plan is to log the response at the client level, and not use the same duplicate code after returning the HttpResponse object.

Logging is simple and universal with this:

if (response == null) {
    Typewriter.technical_error("Response was null");
} else if (response.statusCode() == 201 || response.statusCode() == 200) {
    Typewriter.response(response.body());
} else {
    Typewriter.errorResponse(response.body());
}
  1. Generating requests and sending them

Currently:
Client is first initialized, then a request is generated from the client object and stored in a var, then client is called with that var.

Plan is to make that var into the client object, and just call void methods to send it, and add store the response inside the client object.

Create "HostConfig" class

Description

Currently GenerateFiles read HostConfigFile and parse, which shouldn't be their responsibility, so a new class is required.

Lines like these are going away as well:

if (!configuration.hostConfigFile.path.toFile().exists()) {
    throw new NullPointerException("HostConfigFile is null");
}
  • HostConfig should be responsible for validating itself.
  • GenerateFiles should ask HostConfig to validate itself before asking for correct flows and protocols

Remove marshaling done by Gson in JsonResponse class by creating an ApiResponse class

Description

Currently the JsonResponse class is constructed twice in the Client.java file, once by marshaling it with Gson, and the creating a new JsonResponse with the message, id and the response.statusCode() method.

This will be refactored to use another class, ApiResponse, and using a toJsonResponse() method to convert the HttpResponse inside it to the JsonResponse class

Refactor Client usage so it's declared once instead of multiple times

Description
Currently the Client is created each time a request is sent, consuming resources and possibly disregarding the benefits of connection pooling.

TODO:

  1. Refactor the Client so that it's declared in Main.java, and passed to proper classes
  2. Get the endpoint URI from the CLI arguments and pass it to the Client instead of hard-coded one
  3. [ ] Refactor error response handling so that it accepts string instead of the preformed JSON format

Remove getters

Description

There are still some getters present, so they should be renamed to something more OO.

Regex search get.*\(.*\).*\{ results in 52 matches in 28 files.

Add hubs

ID <38>
Reporter <@MoonBow-1>

Modifications to CFE-18 require a Hub to be sent before Hosts

Dissect Configuration class

The Configuration class should be divided into smaller classes, so they can be passed to other methods/classes more easily and efficiently.

Would be looking at a maximum of 8 classes.

More captureGroups than HostGroups sent

Now that the #3 is pretty much done, RELP groups are in line with the amount of groups sent, but CFE-01 groups differ by 26.

  • 17 of these are due to the missing Host configuration, and are listed in the missingHostDirList.txt file after running the program.
  • The rest require more in-depth investigation for the reason

Remove setters

Setters should be removed and constructors should be used to make the class immutable where applicable

Add new endpoints from CFE-18

ID <30>
Reporter <@MoonBow-1>

CFE-18 has been updated, and the endpoint which have been changed and now there is more of them.

Endpoints to do:

  • storage/flow
  • storage/capture
  • host/relp
  • host/meta/ip
  • host/meta/interface
  • host/group
  • capture/relp - Only 1 hub works, rest are missing Omrelp
  • capture/groups/linkage
  • capture/group

Refactor PromiseInterface to produce different classes for each method

Description

Methods:

RelpGenerateFile getArchiveGenerateFile() throws IOException, JsonParseException;

RelpGenerateFile getMasterGenerateFile(CaptureMetaMap masterCaptureMetaMap)
    throws IOException, JsonParseException;

should return different classes, e.g. ArchiveGenerateFile and MasterGenerateFile.

Prepare for release

Preparing CFE-31 for release.

Issues to fix:

  • Move files from resources to somewhere else
  • Change some of the configuration.properties values to CLI arguments
  • Remove unused dependancy
  • Install CFE-31 in test env
  • Confirm connection to CFE-18

Getters can be substituted for public final fields

If a field is final, it can be made into a public field, removing the getter for it.

private ArchiveDir archivingDir;

public ArchiveDir getArchivingDir() {
  return archivingDir;
}

Can just be made into:

public ArchiveDir archivingDir;

Refactor JSON file read location

Description

CFE-31 should read JSON files "near" their usage place, instead of reading it once and passing the JsonObject around to the required class.
Use case or motivation behind the feature request

Related issues

#32 Issue came up from this, but requires more refactoring than a single class

Additional context

Example of correct implementation was pointed to: https://github.com/teragrep/snw_01/blob/main/src/main/java/com/teragrep/snw_01/tableapi/APIResponse.java#71

Diagrams for CFE-31

ID <4>
Reporter <@MoonBow-1>

There should be a diagram explaining the workflow of the application, all the files it accesses and how it uses those files.
They should also be kept up to date.

Make CFE-31 "ready" for public

Description

CFE-31 is going to be published to GitHub someday, so all the somewhat confidential information should be changed to made-up data wherever possible, mostly tests

Tasks:

  • Refactor tests' configuration instances (contains env specific information)
  • Remove FIXME/TODO that references an env specific file with its FQ path
  • Figure out what to do with the JSON configuration files
  • Change publicly routable IP addresses to localhost
  • Add copyright

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.