ff4j / ff4j

Feature Flags for Java made easy
http://ff4j.org
Apache License 2.0
1.38k stars 276 forks source link

FF4j Audit #217

Closed vinodhvp closed 7 years ago

vinodhvp commented 7 years ago

Hi,

I am working on adding audit features for ff4j. I have added the tables as explained in the below link.

https://github.com/clun/ff4j/blob/master/ff4j-core/src/main/resources/schema-ddl.sql

Can anybody tell me , how to do audit? I am using FeatureStoreSpringJdbc and enabled the audit.

Thanks Vinod

clun commented 7 years ago

Hello,

Thank you for using FF4J. As attributes of the FF4j class you have 3 elements to store data :

By default the 3 are set up with the implementation "InMemory". You probably have set up everything to use the FeatureStore JDBC implementation. You should now set up the EventRepository JDBC configuration.

To add to the confusion (and this my mistake) there are 2 implementations of JDBC. One with core JDBC implementation (to avoid using Spring), in ff4j-core, and one using spring-jdbc in the module "ff4j-store-springjdbc". So far in SpringJDBC I implemented FeatureStore and PropertyStore but not the EventRepository (could be pretty fast as I have all queries ready).

As a conclusion please find here a way to set up your application:

// Initialization of your DataSource
DataSource ds = ...

// Init the framework full in memory
FF4j ff4j = new FF4j();

// Feature States in a RDBMS
FeatureStoreSpringJdbc featureStore= new FeatureStoreSpringJdbc();
featureStore.setDataSource(ds);
ff4j.setFeatureStore(featureStore);

// Properties in RDBMS
PropertyStoreSpringJdbc propertyStore= new PropertyStoreSpringJdbc();
jdbcStore.setDataSource(ds);
ff4j.setPropertiesStore(propertyStore);

// Audit in RDBMS
// So far the implementation with SpringJDBC is not there, leverage on default JDBC
EventRepository auditStore = new JdbcEventRepository(ds);
ff4j.setEventRepository(eventRepository);

ff4j.audit(true);

Will add this as part of the wiki as well

clun commented 7 years ago

https://github.com/clun/ff4j/wiki/Store-Technologies#jdbc

My pleasure :)

clun commented 7 years ago

Added the expected store

clun commented 7 years ago

Part of 1.6.4 released 2017_05_01

abuinteam commented 6 years ago

Hi Clun,

I am trying FF4J for my organization for my existing Struts / Servlet project. I am get the basic things up and running. I can create a feature and use it JSP/Java etc. But I have encountered some issues which I am not able to proceed further.

I am using MS SQL Server as my feature/property/event stores and using 1.6.5 ff4j jars.

Below is my FF4JProvider implemenatation,

public TeamFF4JProvider() { /ff4j = new FF4j("ff4j.xml");/ BasicDataSource dbcpDataSource = new BasicDataSource(); dbcpDataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); dbcpDataSource.setUsername(""); dbcpDataSource.setPassword("**"); dbcpDataSource.setUrl("");
ff4j = new FF4j(); final JdbcFeatureStore jdbcFeatureStore = new JdbcFeatureStore(dbcpDataSource); final JdbcPropertyStore jdbcPropertyStore = new JdbcPropertyStore(dbcpDataSource); FeatureStore featureStore = new FeatureStoreAuditProxy(ff4j, jdbcFeatureStore); PropertyStore propertyStore = new PropertyStoreAuditProxy(ff4j, jdbcPropertyStore); ff4j.setFeatureStore(featureStore); ff4j.setPropertiesStore(propertyStore); ff4j.setEventRepository(new JdbcEventRepository(dbcpDataSource)); // Enable Audit Proxy ff4j.audit(true); ff4j.autoCreate(true); }

  1. How to enable auditing. I created all the audit tables and set audit as true. But I am not seeing any audit entries getting inserted.

  2. How to enable caching? Any documentation for this?

  3. How to implement feature toggle at the javascript/css level? Any examples?

  4. What is the best practice to remove the feature flag in a agile project? Any recommendations? What should I do if my feature flag are increasing in each release? When should I remove those?

Thanks In Advance.

clun commented 6 years ago

Hello,

(1) - How to enable auditing.

(2) - How to enable caching? Any documentation for this?

(3) - How to implement feature toggle at the javascript/css level? Any examples?

(4) - What is the best practice to remove the feature flag in a agile project? Any recommendations? What should I do if my feature flag are increasing in each release? When should I remove those?

2017-10-30 5:20 GMT+01:00 abuinteam notifications@github.com:

Hi Clun,

I am trying FF4J for my organization for my existing Struts / Servlet project. I am get the basic things up and running. I can create a feature and use it JSP/Java etc. But I have encountered some issues which I am not able to proceed further.

I am using MS SQL Server as my feature/property/event stores.

Below is my FF4JProvider implemenatation,

public TeamFF4JProvider() { /ff4j = new FF4j("ff4j.xml");/ BasicDataSource dbcpDataSource = new BasicDataSource(); dbcpDataSource.setDriverClassName("com.microsoft.sqlserver.jdbc. SQLServerDriver"); dbcpDataSource.setUsername("

*"); dbcpDataSource.setPassword("*"); dbcpDataSource.setUrl(""); ff4j = new FF4j(); final JdbcFeatureStore jdbcFeatureStore = new JdbcFeatureStore( dbcpDataSource); final JdbcPropertyStore jdbcPropertyStore = new JdbcPropertyStore( dbcpDataSource); FeatureStore featureStore = new FeatureStoreAuditProxy(ff4j, jdbcFeatureStore); PropertyStore propertyStore = new PropertyStoreAuditProxy(ff4j, jdbcPropertyStore); ff4j.setFeatureStore(featureStore); ff4j.setPropertiesStore(propertyStore); ff4j.setEventRepository(new JdbcEventRepository(dbcpDataSource)); // Enable Audit Proxy ff4j.audit(true); ff4j.autoCreate(true); }

1.

How to enable auditing. I created all the audit tables and set audit as true. But I am not seeing any audit entries getting inserted. 2.

How to enable caching? Any documentation for this? 3.

How to implement feature toggle at the javascript/css level? Any examples? 4.

What is the best practice to remove the feature flag in a agile project? Any recommendations? What should I do if my feature flag are increasing in each release? When should I remove those?

Thanks In Advance.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/clun/ff4j/issues/217#issuecomment-340340239, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsWCG5ycigToMCbYvX4McTJ1pGK9Ewkks5sxU6jgaJpZM4M42PO .

--

Cédrick

*"Try not to become a man of success, but rather try to become a man of value." (*Albert Einstein)

abuinteam commented 6 years ago

Thank you very much Clun. I will try these example and will update my comments.

abuinteam commented 6 years ago

Hi Clun,

Again Thank you very much. The below are my observations. I will try the cache tomorrow.

  1. Auditing/Graph are not working with SQL Server. I tried with MySQL. Auditing is working fine. I was getting an error "Operand type clash: datetime2 is incompatible with timestamp" using MSSQL "timestamp" datatype in SQL Server

  2. Feature update is not working fine. I am getting an error message. Getting an error "Cannot update features database, SQL ERROR"

  3. I feel the graph's are showing wrong numbers. I just hit the page couple of times but the count seems to be not matching.

  4. How can I secure the admin console and rest api? Any documentation available?

  5. How to assign roles? Any documentation for integrating with Spring Security or Apache Shiro?

clun commented 6 years ago
  1. We might say there is problem with SQLServer and JDBCEventrepository => have to check the support of Timestamp datatype in SQLServer, may required a dedicated DDL. (was the case for DB2)

  2. Can you confirm this appears with SQLServer again ? Could you give me the version 2014/2016. For 2016 i know there is a param to enable to understand older SQL but not sure it it's relevant here.

  3. I will provide you a working example, the hit will be updated it the feature is toggled on and use in JSP or underlying service. I am sure it works, a matter of configuration here.

  4. To secure admin console/ REST API please have a look #245

  5. Spring Security : Roles=GrantedAuthority so part of Spring security conf

Sample : SpringConf https://github.com/clun/ff4j-samples/blob/master/ff4j-demo/src/main/resources/applicationContext-security.xml Sample FF4J conf : https://github.com/clun/ff4j-samples/blob/master/ff4j-demo/src/main/resources/applicationContext.xml#L29

abuinteam commented 6 years ago

Thank you Clun.

  1. Forgot to mention. Point 2 happens in MySQL not SQL Server. I am using the version 5.7.20.

Since SQL Server is having the audit issue I am using MySQL.

Thank you for other links. I am looking into the links.

abuinteam commented 6 years ago

Hi Clun,

  1. I was trying simple EhCache. Unfortunately I could not able to find JHipsterEhCacheCacheManager. Which jar file I have include in my project.

  2. In the meantime I tried the below implementation from ff4j-store-ehcache-1.6.5.jar, I didnt see any errors but the flags are not working.

    // EHCACHE FF4JCacheManager ff4jCache = new FeatureCacheProviderEhCache(); ff4j.cache(ff4jCache);

  3. I did see my console is showing ehcache as cachemanager but when I click ClearCache it goes to a blank page. What really happens when I hit ClearCache?

  4. How DB and Cache works in FF4J. If I make a feature on to off will it go to cache first and DB or DB first and cache?

Thanks Abuthahir

abuinteam commented 6 years ago

Hi Clun,

Can you please help me on the EhCache part?

clun commented 6 years ago

Yes, sorry for delay. Will answer today on all mater (Caching, Securityà

clun commented 6 years ago

For Ehcache I updated the documentation : https://github.com/clun/ff4j/wiki/Advanced-Concepts#caching

hamza-mahwachi commented 4 years ago

Bonjour clun,

j'ai configuré FF4J avec H2 database et HIKARI datasource , l'EventRepositorySpringJdbc ne focntionne pas, je cree des features et je les trouve dans la base mais je fais enable/disable feature ceci n'est pas sauvegardé dans la table ff4j_audit ,elle est toujours vide

@Bean public HikariDataSource dataSource() { HikariDataSource jdbc = new HikariDataSource(); jdbc.setJdbcUrl(jdbcUrl); jdbc.setPassword(jdbcPassword); jdbc.setUsername(jdbcUserName); return jdbc; }

@Bean
public FF4j getFF4j(HikariDataSource dataSource) {
    FF4j ff4j = new FF4j();
    ff4j.setFeatureStore(new FeatureStoreSpringJdbc(dataSource));
    ff4j.setPropertiesStore(new PropertyStoreSpringJdbc(dataSource));
    ff4j.setEventRepository(new EventRepositorySpringJdbc(dataSource));
    ff4j.audit(true);
    return ff4j;
}