Apergy to acquire Ecolab's upstream energy unit in a $3.9 billion deal